HTTP (methods, status code, & headers) Flashcards
Used by HTTP request messages in the request line.
Methods
Indicates the desired action for the specified resource.
Method
HTTP methods are sometimes called ________ because of the verb-like naming scheme.
HTTP Verbs
Used to request a specific resource from the server.
GET
Method meant to be read only, and not modify the server’s state.
GET
Used to submit data to a server.
POST
Acording to W3C, POST is designed to cover 4 functions:
- annotation of existing resources
- posting a message to board
- providing a block of data
- extending a database through an append operation
Unlike GET, POST requests often result in some ____________ in the server.
state change
The expected response of this is identical to a response to a GET request with the same path, headers, etc. but without the response body.
HEAD
Used for checking link validity, recent modification, or just to find out more about the resource without actually fetching it.
HEAD
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
Used to ask the server about its supported methods.
OPTIONS
Can be used to ask what methods are supported by the server in total or what methods are supported for specific resources in the server.
OPTIONS
Used to apply partial modification to the data in the specified URL.
PATCH
HTTP Methods that correspond to CRUD operations.
PUT
GET
POST/PATCH
DELETE
To ensure compatibility between servers and their clients, all parties are expected to ____________________.
stick to the defined conventions.
What are the three characteristics of HTTP Methods.
Safe
Idempotent
Cacheable
Methods that do not alter the state of the server. In other words, a read-only operation.
Safe Methods
These methods when applied several times do not change the result of the initial application.
Idempotent
Methods that leave the server in the same state whether the request was done once or repeated several times.
Idempotent
All ______ methods are also idempotent since they don’t change the server’s state.
If this methods is used in the request, the response is considered cacheable.
Cacheable
Only ____ and _____ methods are cacheable.
HEAD and GET
A 3-digit code found in the first line of HTTP response messages.
HTTP Status Code
Indicates whether a request was successful or not (and why).
Status Code
Each status code has a corresponding ______ or ________ that it included next to the status code.
Reason Phrase or Status Message
Status codes can be classified into 5 groups, what are they?
100-199: Informational
200-299: Success
300-399: Redirection
400-499: Client Error
500-599: Server Error
These indicate that the client’s request was successfully received, understood, and processed.
200 range - success
The request has succeeded. The meaning varies depending on the HTTP Method of the request.
200 - OK
The request was a success and a new resource was a created as a result
201 - Created
Indicate that further action needs to be taken by the client in order for the request to be processed.
300 range
The URL requested refers to multiple resources. This code is returned with a list of options the client can select from.
300 Multiple Choices
The resource has been moved to a different URL. The new URL is indicated by the Location header in the response.
301 Moved Permanently
Like 301 but the move is temporary. Browsers redirect to the temporary URL but crawlers don’t update their databases.
302 Found
The resource hasn’t been modified iso there’s no need to retransmit the data. Refer to a cached copy instead.
304 Not Modified
These indicated that the server failed to process the request and that the client is the cause of the error.
400 - error
These are usually caused by badly formed requests or nonexistent URLs
400 - error
The client sent a request message with invalid syntax.
400 - Bad Request
The request was not acted upon because it lacks valid authentication credentials.
401 Unauthorized
The server understood the request but will not authorize it
403 - Forbidden
There is no resource found in the specified URL
404 Not Found
The method used in the request isn’t supported for the specified resource
405 - Method Not Allowed
Access to the target resource is no longer available
410 - Gone
The client sent an entity body larger than the sever can or wants to process.
413 Request Entity Too Large
The client sent a request with a URL longer than the server can or wants to process.
414 Request URI Too Long
The content type of the request payload is not supported by the server
415 Unsupported Media Type
These indicated that the server failed to process the request and that the server was the cause of the error.
500 - server errors
Common causes: server limitations, error in server components, proxy errors.
500 - server errors
Generic server error message. The server encountered an error but can’t give a more specific status code.
500 Internal Error
The server does not support the functionality to fulfill the request.
501 Not Implemented
The server does not recognize the request method at all.
501 Not Implemented
The server isn’t ready to handle the request. Commonly request by server overload or server maintenance.
503 Service Unavailable
The server can use the Retry-After to indicate how much time the client should wait before trying again.
503 Service Unavailable
The server couldn’t get response in time from the next entity.
504 Gateway Timeout
The server doesn’t support the HTTP version used in the request message.
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 - Informational
The client should continue with the request or ignore the response if it’s already finished.
100 Continue
The server is switching protocols requested by the client.
101 Switching Protocols.
This header specify to switch to the protocol requested by the client.
Upgrade Header
Allow the client and server to pass additional information in request and response messages.
Headers
Work together to determine what clients and servers do.
Headers and Methods
Give additional context to status codes.
Headers
Used by both request and response messages.
HTTP Headers
4 types of Headers
General Headers
Request Headers
Response Headers
Entity Headers
Can be used for both request and response messages.
General Headers
They contain general information that does not apply to the contents of the message body.
General headers+
Examples of General Headers
Date, Cache-Control, Conenction
Used only in request messages.
Request Headers
May contain info about the resource requested, or the client itself.
Request Headers
Examples of Request Headers
Accept
Accept-Charset
Accept-Encoding
Accept-Language
Request header where client request a new copy of the resource if it has been modified since the specified date.
If-Modified-Since
Details about the browser, rendering engine, PS. architecture
User-Agent
Cookies set by the server
Cookie
Used to give more detailed information about the response
Response Headers
How much time 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
Can be used by both request and response messages.
Entity Header
The only header to describe the content of the message body
Entity Header
Contain information about the payload such as:
Content Length
Language
Encoding
Type
Location
Date of last modification
Can be used by clients and servers to negotiate what kind of resource is sent between them.
Conditional Request Headers and entity headers.
Value of the content-type header indicates the ___________ of the payload content.
MIME Type
Helps the receiving entity decide what to do with the data.
Multipurpose Internet Mail Extension
Sample MIME Types
Text/css
Text/html
application/zip
application/powerpoint
application/pdf
HTTP is meant to be ________. Developers can make up their own headers, status codes, or methods. Though this might cause interoperability issues.
Extensible