According to the standard HTTP/1.1 protocol, HTTP request methods include
GET, HEAD, OPTIONS, POST, PUT, PATCH, DELETE
.GET
retrieves the specified resource from the server.
HEAD
retrieves only the HTTP response headers for the specified resource (ignores the body).
OPTIONS
is a special request used to check if a server supports a certain request method. For example, a client can first send an OPTIONS request to ask if the server supports PUT. If it does, then a PUT request can be sent.
POST
submits data from the client to the server.
PUT
updates an existing resource on the server.
PATCH
also updates an existing resource on the server, but only transmits the modified parts incrementally.
DELETE
removes a resource from the server.
GET
, HEAD
, and POST
requests were supported by HTTP/1.0, while OPTIONS
, PUT
, PATCH
, and DELETE
were added by HTTP/1.1.According to the specification,
GET
, HEAD
, and OPTIONS
requests do not change data on the HTTP server and are therefore safe.According to the specification, all requests except
POST
and PATCH
can be called once or multiple times in the same way with the same side effects, making them idempotent.According to the specification, multiple calls to the
POST
method may create multiple resources, making it non-idempotent. The PATCH
method may incrementally add multiple pieces of content, making it also non-idempotent.According to the specification,
GET
and OPTIONS
requests can be cached, while other requests cannot. More details about caching will be discussed in later courses.Â
Reposne type
Type | Description | Typical Examples |
text | Indicates that the file is plain text, theoretically readable by humans | text/plain, text/html, text/css, text/javascript |
image | Indicates that it is some kind of image. Does not include videos, but dynamic images (such as animated gifs) also use the image type | image/gif, image/png, image/jpeg, image/bmp, image/webp, image/x-icon |
audio | Indicates that it is some kind of audio file | audio/midi, audio/mpeg, audio/webm, audio/ogg, audio/wav |
video | Indicates that it is some kind of video file | video/webm, video/ogg |
application | Indicates that it is some kind of binary data | application/octet-stream, application/pkcs12, application/vnd.mspowerpoint, application/xhtml+xml, application/xml, application/pdf |