HTTP (Methods & Response codes)
HTTP
Hyper text transport protocol
•History
•HTTP Methods
•HTTP Headers (General/Request/Response)
•HTTP Response Codes
History
•HTTP was created in the early 1990s and has been extended several times.
HTTP/0.9, HTTP/1.0, HTTP/1.1, and the modern HTTP/2
•A textual format to represent hypertext documents, the HyperText Markup Language (HTML).
•A simple protocol to exchange these documents, the HyperText Transfer Protocol (HTTP).
HTTP Methods
The set of common methods for HTTP/1.1 is defined below and this set can be expanded based on requirements. These method names are
case sensitive and they must be used in uppercase.
S.N. Method and Description
1 GET : The GET method is used to retrieve information from the given server using a given URI. Requests using GET should only
retrieve data and should have no other effect on the data.
2 HEAD : Same as GET, but transfers the status line and header section only.
3 POST : A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms.
4 PUT : Replaces all current representations of the target resource with the uploaded content.
5 DELETE : Removes all current representations of the target resource given by a URI.
6 CONNECT : Establishes a tunnel to the server identified by a given URI.
7 OPTIONS : Describes the communication options for the target resource.
8 TRACE : Performs a message loop-back test along the path to the target resource.
HTTP Headers
HTTP header fields provide required information about the request or response, or about the object sent in the message body. There are four
types of HTTP message headers:
•General-header: These header fields have general applicability for both request and response messages.
•Client Request-header: These header fields have applicability only for request messages.
•Server Response-header: These header fields have applicability only for response messages.
•Entity-header: These header fields define meta information about the entity-body or, if no body is present, about the resource identified by the
request.
HTTP Response Codes
The Status-Code element in a server response, is a 3-digit integer where the first digit of the Status-Code defines the class of response and the
last two digits do not have any categorization role. There are 5 values for the first digit:
S.N. Code and Description
1 1xx: Informational It means the request has been received and the process is continuing.
2 2xx: Success It means the action was successfully received, understood, and accepted.
3 3xx: Redirection It means further action must be taken in order to complete the request.
4 4xx: Client Error It means the request contains incorrect syntax or cannot be fulfilled.
5 5xx: Server Error It means the server failed to fulfill an apparently valid request.
1xx: Information
Message Description
100 Continue Only a part of the request has been received by the server, but as long as it has not been rejected, the
client should continue with the request.
101 Switching Protocols The server switches protocol.
2xx: Successful
Message Description
200 OK The request is OK.
201 Created The request is complete, and a new resource is created .
202 Accepted The request is accepted for processing, but the processing is not complete.
203 Non-authoritative Information The information in the entity header is from a local or third-party copy, not from the original
server.
204 No Content A status code and a header are given in the response, but there is no entity-body in the
reply.
205 Reset Content The browser should clear the form used for this transaction for additional input.
206 Partial Content The server is returning partial data of the size requested. Used in response to a request
specifying a Range header. The server must specify the range included in the response with
the Content-Range header.
3xx: Redirection
Message Description
300 Multiple Choices A link list. The user can select a link and go to that location. Maximum five addresses .
301 Moved Permanently The requested page has moved to a new url .
302 Found The requested page has moved temporarily to a new url .
303 See Other The requested page can be found under a different url .
304 Not Modified This is the response code to an If-Modified-Since or If-None-Match header, where the URL has not been
modified since the specified date.
305 Use Proxy The requested URL must be accessed through the proxy mentioned in the Location header.
306 Unused This code was used in a previous version. It is no longer used, but the code is reserved.
307 Temporary Redirect The requested page has moved temporarily to a new url.
4xx: Client Error
Message Description
400 Bad Request The server did not understand the request.
401 Unauthorized The requested page needs a username and a password.
402 Payment Required You can not use this code yet.
403 Forbidden Access is forbidden to the requested page.
404 Not Found The server can not find the requested page.
405 Method Not Allowed The method specified in the request is not allowed.
406 Not Acceptable The server can only generate a response that is not accepted by the client.
407 Proxy Authentication Required You must authenticate with a proxy server before this request can be served.
408 Request Timeout The request took longer than the server was prepared to wait.
409 Conflict The request could not be completed because of a conflict.
400 Bad Request The server did not understand the request.
401 Unauthorized The requested page needs a username and a password.
402 Payment Required You can not use this code yet.
403 Forbidden Access is forbidden to the requested page.
404 Not Found The server can not find the requested page.
405 Method Not Allowed The method specified in the request is not allowed.
406 Not Acceptable The server can only generate a response that is not accepted by the client.
407 Proxy Authentication Required You must authenticate with a proxy server before this request can be served.
408 Request Timeout The request took longer than the server was prepared to wait.
409 Conflict The request could not be completed because of a conflict.
5xx: Server Error
Message Description
500 Internal Server Error The request was not completed. The server met an unexpected condition.
501 Not Implemented The request was not completed. The server did not support the functionality required.
502 Bad Gateway The request was not completed. The server received an invalid response from the upstream
server.
503 Service Unavailable The request was not completed. The server is temporarily overloading or down.
504 Gateway Timeout The gateway has timed out.
505 HTTP Version Not Supported The server does not support the "http protocol" version.
=================== END OF DOCUMENT ===================