HTTP Flashcards
What is HTTP?
Hypertext Transfer Protocol? It is a stateless, application layer protocol for communicating between distributed systems
How can HTTP support communication between a variety of host and clients and a mixture of networks configurations?
It assumes very little about a particular system and does not keep state between different message exchanges
Why is HTTP a stateless protocol?
It assumes very little about a particular system and does not keep state between different message exchanges
What protocol is the basis of HTTP?
TCP/IP or any other reliable protocol
What are the versions of HTTP?
HTTP/1.0, HTTP/1.1 and HTTP/2
What are the main differences between HTTP/1.0 and HTTP/1.1?
Persistent connections, chunked transfer-coding, fine grained caching headers.
What URL stands for?
Uniform Resource Locator
What is a URL structure consisted of?
Protocol + Host + Port + Resource Path + Query: http://www.google.com:80/search?q=cats
What is the resource path of a URL?
It is the local path to the resource on the server
What is a HTTP verb?
The action that should be performed on the host
What are the request verbs?
GET, POST, PUT, DELETE, HEAD, TRACE, OPTIONS, CONNECT
What does the GET verb?
Fetch an existing resource. The URL contains all the necessary information the server needs to locate and return the resource
What does the POST verb?
create a new resource. PORT requests usually carry a payload that specifies the data for the new resource
What does the PUT verb?
Update an existing resource. The payload may contain the updated data for the resource
What does the DELETE verb?
Delete an existing resource
Are PUT and DELETE specialized versions of the POST verb?
Yes. They may be packaged as POST requests with the payload containing the exact action: create, update or delete
What does the HEAD verb?
Similar to GET but without the message body. It is used to retrieve the server headers for a particular resource, generally to check if the resource has changed via timestamps
What does the TRACE verb?
Used to retrieve the hops that a request takes to round trip from the server. Each intermediate proxy or gateway would inject its IP or DNS name into the “Via” header field. This can be used for diagnostic purposes.
What does the OPTIONS verb?
Used to retrieve the server capabilities. On the client side it can be used to modify the request based on what the server can support
What does the CONNECT verb?
Stabilises a tunnel
What is a proxy?
It is a server that acts as an intermediary for requests from clients seeking resources from other servers.
What is a gateway?
Is a component that is part of two networks, which use different protocols. The gateway will translate one protocol into the other. A router is a special case of a gateway.
What are status codes?
It is part of the server response that tells the client how to interpret it
A header required to be accepted by all HTTP/1.1 clients
Transfer-Encoding
To what class does the status code 1xx belongs?
Informational messages. Provisional class introduced in HTTP/1.1. The server can send a “Expect: 100-continue” message, telling the client to continue sending the remainder of the request, or ignore it if it has already sent it. HTTP/1.o clients ignore this header.
To what class does the status code 2xx belongs?
Successful. Tells the client that the request was successfully processed.
What does the status code 200 means?
OK
What does the status code 202 means?
Accepted. Request was accepted but may not include the resource in the response. This is useful for async processing on the server side. The server may choose to send information for monitoring.
What does the status code 204 means?
No content. There is no message body in the response.
What does the status code 205 means?
Resent content. Indicates to the client to reset its document view.
What does the status code 206 means?
Partial content. Indicates that the response contains partial content. Additional headers indicate the exact range and content expiration information.
To what class does the status code 3xx belongs?
Redirection. This requires the client to take additional action.
What does the status code 301 means?
Moved Permanently. The resource is now located at a new URL
What does the status code 303 means?
See other. The resource is temporarily located at a new URL. The “Location” response header contains the temporary URL.
What does the status code 304 means?
Not Modified. The server has determined that the resource has not changed and the client should use its cached copy.
What is ETag?
Entity Tag. A hash of the client’s content. The server compares this with its own to check for modifications.
To what class does the status code 4xx belongs?
Client Error. These codes are used when the server thinks that the client is at fault, either by requesting an invalid resource or making a bad request.
What does the status code 400 means?
Bad request. The request was malformed.
What does the status code 401 means?
Unauthorized. Request requires authentication. The client can repeat the request with the Authorization header.
What does the status code 403 means?
Forbidden. Server has denied access to the resource
What does the status code 405 means?
Method not allowed. Invalid HTTP verb used in the request line, or server does not support that verb.
What does the status code 409 means?
Conflict. Server could not complete the request because the client is trying to modify a resource that is newer than the client’s timestamp.
To what class does the status code 5xx belongs?
Server Error. Used to indicate a server failure while processing the request.
What does the status code 501 means?
Not implemented. The server does not yet support the requested functionality
What does the status code 503 means?
Service unavailable. Internal system failed or the server is overloaded.
Transfer-Encoding: chunked means?
That the message body will be send in pieces. All HTTP/1.1 are required to accept it.
What are the general headers?
Cache-Control Connection Date Pragma Trailer Transfer-Encoding Upgrade Via Warning
Via header is…
Used in TRACE message and updated by all intermittent proxies and gateways
Pragma header is…
Considered a custom header and may be used to include implementation-specif headers
Date header is…
Used to timestamp the request/response message
Upgrade header is…
Used to switch protocols and allow a smooth transition to a newer protocol
Transfer-Encoder header is…
Generally used to break the response into smaller parts with the Transfer-Encoding: chunked value (HTTP/1.1)
What are the entity headers?
Allow Content-Encoding Content-Language Content-Length Content-Location Content-MD5 Content-Range Content-Type Expires Last-Modified
Custom/Unknown headers will be treated as … by the HTTP protocol.
Entity headers
Example of request message
GET /articles HTTP/1.1 Host: www.articles.com (mandatory for HTTP/1.1) Connection: keep-alive Cache-Control: no-cache Pragma: no-cache Accept: text/html, application/xhtml+xml
Example of a response status-line
HTTP/1.1 200 OK