Skip to Content
RESTful Web Services Cookbook
book

RESTful Web Services Cookbook

by Subbu Allamaraju
March 2010
Intermediate to advanced
312 pages
7h 31m
English
O'Reilly Media, Inc.
Content preview from RESTful Web Services Cookbook

Appendix C. HTTP Methods

HTTP’s uniform interface consists of the OPTIONS, GET, HEAD, POST, PUT, DELETE, and TRACE methods. This appendix provides a short primer on using these HTTP methods, listed in the order used by RFC 2616.

OPTIONS

Use this method to find the list of HTTP methods supported by any resource or to ping the server.

Request: Headers but no body.

Response: Headers but no body by default. The server may provide a description of the resource in the body.

Examples:

# 1. Request to find methods supported by a resource
OPTIONS /movie/gone_with_the_wind HTTP/1.1
Host: www.example.org

# Response with the methods supported by the resource
HTTP/1.1 204 No Content
Allow: HEAD, GET, OPTIONS, PUT, DELETE

# 2. Request to ping the server or find the version of HTTP supported
OPTIONS * HTTP/1.1
Host: www.example.org

# Response
HTTP/1.1 204 No Content

GET

Use this method to retrieve a representation of a resource.

Request: Headers but no body specified by HTTP 1.1.

Response: A representation of the resource at the request URI usually with a body. Response headers such as Content-Type, Content-Length, Content-Language, Last-Modified, and ETag correspond to the representation in the response.

Examples:

# A request to get a representation of a resource
GET /tx/1234 HTTP/1.1
Host: www.example.org

# Response
HTTP/1.1 200 OK
Content-Type: application/xml;charset=UTF-8
Content-Length: xxx

<status>
...
</status>

HEAD

Use this method to retrieve the same headers as that of a GET response but without ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

RESTful Web Services

RESTful Web Services

Leonard Richardson, Sam Ruby
RESTful Web Clients

RESTful Web Clients

Mike Amundsen

Publisher Resources

ISBN: 9780596809140Errata Page