HTTP Methods, Status Codes, & Headers Flashcards
_________ are used by HTTP request messages in the request line.
Methods
GET /home HTTP/1.1
What is the method?
GET
_________ indicates the desired action for the specified resource.
Methods
GET /home HTTP/1.1
What is the “action”?
GET
GET /home HTTP/1.1
What is the resource path?
/home
Methods are sometimes called _________ because of the verb-like naming scheme.
HTTP Verbs
Used to request a specific resource from the server.
GET
GET requests are meant to be _________, and not modify the server’s state.
read only
Used to submit data to a server.
POST
POST is designed to cover the 4 functions:
1) Annotation of existing resources
2) Posting a message to a bulletin board,
newsgroup, mailing list, etc.
3) Providing a block of data, such as the result
of submitting a form, to a data-handling
process
4) Extending a database through an append operation
The actual behavior of a server in response to a POST request depends on the _________.
server
POST requests often result in some
_________ in the server
State change
Used for checking link validity, recent modification, or just to find out more about the resource without actually fetching it.
HEAD
The expected response of a HEAD request is identical to a response to a GET request with the same path, headers, etc. but without the _________.
response body
Replaces current resource in the specified path with the data in the request body.
PUT
Deletes the resource in the specified path.
DELETE
Used by the client to establish a connection to the server over a tunnel proxy.
CONNECT
Used to echo the contents of an HTTP Request back to the client.
TRACE
Useful for checking how the request is modified by proxies on its way to the server.
TRACE
Generally for debugging.
TRACE
Used to ask the server about its supported methods.
OPTIONS
_________ can be used to ask what methods are supported by the server in total.
OPTIONS
Used to apply partial modification to the data in the specified URL.
PATCH
(T or F)
Some methods correspond to the CRUD operations.
True
The HTTP Methods can be characterized with any combination of the following:
Safe
Idempotent
Cacheable
These do not alter the state of the server.
Safe Methods
A read-only operation.
Safe Methods
The property of certain operations such that they can be applied several times without changing the result of the initial application.
Idempotency
These methods exhibit idempotency.
Idempotent Methods
(T or F)
An HTTP request with an idempotent method leaves the server in the same state whether the request was done once or repeated several times.
True
All safe methods are also _________.
idempotent
Only ____and ____ are cacheable.
HEAD, GET
If the method used in the request is cacheable,
then the response is considered _________.
cacheable
A 3-digit code found in the first line of HTTP response messages.
HTTP Status Codes
HTTP/1.1 200 OK
What is the Status Code?
200
_________ indicate whether a request was
successful or not (and why).
Status Codes
Each status code has a corresponding _________ or _________ that is included next to the status code.
reason phrase, status message
HTTP/1.1 200 OK
What is the Reason Phrase?
OK
The status codes can be classified into _________.
5 groups
Status Codes classification:
100-199 : _________
200-299 : _________
300-399 : _________
400-499 : _________
500-599 : _________
100-199 : Informational
200-299 : Success
300-399 : Redirection
400-499 : Client Error
500-599 : Server Error
(T or F)
There are 100 codes for each group.
False
_________ indicate that the client’s request was successfully received, understood, and processed.
Status Codes
200 range
A generic success message.
Status Codes
200 OK
The request was a success and a new resource was created as a result (e.g. in response to PUT).
Status Codes
201 Created
_________ codes indicate neither failure nor success.
300 range
_________ indicate that further action needs to be taken by the client in order for the request to be processed.
300 range codes
The URL requested refers to multiple resources.
This code is returned with a list of options the
client can select from.
Status Codes
300 Multiple Choices
The resource has been moved to a different URL.
The new URL is indicated by the Location header in the response.
Status Codes
301 Moved Permanently
Like 301, but the move is temporary. Browsers
redirect to the temporary URL but crawlers don’t
update their databases.
Status Codes
302 Found
The resource hasn’t been modified so there’s no
need to retransmit the data. Refer to a cached copy instead.
Status Codes
304 Not Modified
These indicate that the server failed to process the request and that the client is the cause of the error.
Status Codes
400 range
Usually caused by badly formed requests or nonexistent URLs.
Status Codes
400 range
The client sent a request message with invalid syntax.
Status Codes
400 Bad Request
The request was not acted upon because it lacks
valid authentication credentials.
Status Codes
401 Unauthorized
The server understood the request but will not authorize it.
Status Codes
403 Forbidden
Similar to 401, but logging in will make no difference. The client has no permission to access
the URL’s resource.
Status Codes
403 Forbidden
There is no resource found in the specified URL.
Status Codes
404 Not found
The method used in the request isn’t supported for the specified resource.
Status Codes
405 Method Not Allowed
Access to the target resource is no longer available.
Status Codes
410 Gone
The client sent an entity body larger than the
server can or wants to process.
Status Codes
413 Request Entity Too Large
The client sent a request with a URL longer than
the server can or wants to process.
Status Codes
414 Request URI Too Long
The content type of the request payload is not supported by the server.
Status Codes
415 Unsupported Media Type
These indicate that the server failed to process the request and that the server was the cause of the error.
500 range
Common causes for server error:
Server limitations
Error in server components
Proxy errors
Generic server error message. The server encountered an error but can’t give a more specific status code.
Status Codes
500 Internal Error
The server does not support the functionality to
fulfill the request.Use case: The server doesn’t recognize the request method at all.
Status Codes
501 Not Implemented
The server isn’t ready to handle the request.
Used for temporary conditions.
Status Codes
503 Service Unavailable
503 Service Unavailable is commonly caused by _________.
server overload or server maintenance
(in 503 Service Unavailable)
The server can use the _________ to
indicate how much time the client should wait
before trying again.
Retry-After header
The server (acting as a proxy) couldn’t get a
response in time from the next entity.
Status Codes
504 Gateway Timeout
The server doesn’t support the HTTP version used in the request message.
Status Codes
505 HTTP Version Not Supported
These provide additional info about the request,
but not info about whether the request was a
success or fail.
100 range
The client should continue with the request or
ignore the response if it’s already finished.
Status Codes
100 Continue
The server is switching to the protocol requested
by the client (specified by the ‘Upgrade’ header).
Status Codes
101 Switching Protocols
_________ allow the client and server to pass
additional information in request and response
messages.
Headers
_________ and _________work together to determine what clients and servers do.
Headers, methods
_________ give additional context to status codes.
Headers
(T or F)
HTTP Headers are used by both request and response messages .
True
4 Types of Headers
General Headers
Request Headers
Response Headers
Entity Headers
_________ can be used for both request and response messages.
General Headers
Examples of Request Headers:
Accept
Accept-Charset
Accept-Encoding
Accept-Language
_________ are only used in request
messages.
Request headers
They may contain info about the resource requested, or the client itself.
Request headers
- Client requests a new copy of the resource if it has been modified since the specified date.
- If the resource hasn’t been modified, client receives 304 and uses a cached copy instead.
If-Modified-Since
Examples of General Headers:
Date
Cache-Control
Connection
Details about the browser, rendering engine, OS, architecture.
User-Agent
Cookies set by the server.
Cookie
Used to give more detailed information about the response.
Response Headers
How much time (in sec) the response has been in a proxy cache.
Age
Indicates the redirection URL. Used in
conjunction with 300 range codes.
Location
Details about the server’s software.
Server
_________ describe the content of the message body.
Entity Header
Entity Header can contain information about the payload such as:
●Content length
● Language
● Encoding
● Location
● Type
● Date of last modification
(T or F)
Conditional request headers and entity headers can be used by clients and servers to negotiate what kind of resource is sent between them.
True
The value of the Content-Type header indicates the _________ of the payload content.
MIME Type
Sample MIME Types:
❏ text/css
❏ text/html
❏ application/zip
❏ application/powerpoint
❏ application/pdf
(T or F)
HTTP is meant to be extensible.
True
_________ help the receiving entity decide what to do with the data.
MIME Type
(T or F)
Developers can make up their own headers, status codes, or methods.
True
(though this might cause
interoperability issues)