Request (HTTP) in HTTP
A Client sends an HTTP request to a Server in the form a request message that includes the following format.
A Client sends an HTTP request to a Server in the form with a request message that includes the following format:
- A request line
- No more or more Header fields (General | Request | Entity) are followed by CRLF.
- A blank line (for example, a line with nothing before CRLF) indicates the end of the Header field.
- An informative body part
The following sections explain the usage of each object in the HTTP request message.
Request line
The Request line starts with a method procedure, followed by a Request-URI and protocol version, and ends with CRLF. Elements are separated by SP space characters.
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
Below discuss each section mentioned in the Request Line.
Required method
The method requires only the method to be executed on the source identified by the Request-URI provided. Method is case-intensive and should always be mentioned in uppercase. The following table lists all the methods supported in HTTP / 1.1.
Formula and Description1 GETGET is used to retrieve information from the server provided by using a provided URI. Requests use GET so only the data is received and should not affect the data.
2 HEADSimilar to GET, but it transmits the status line and the Header area.
3 POSTA POST request is used to send data to the Server, for example, customer information, file uploads, etc., using HTML templates.
4 PUTChange all current representatives of the target source with the uploaded content.
5 DELETERemove all the current representation of the target source by URI.
6 CONNECTSetting a tunnel to the Server defined by the URI provided.
7 OPTIONSDescribe the communication functions for the target source.
8 TRACEPresent a loop that checks the message in parallel with path to the target source.
Request-URI
The Request-URI is a Uniform Source Identifier (URI) and identifies the source to which the request is applied. The following are common patterns used to identify a URI:
Request-URI = "*" | absoluteURI | abs_path | authorityFormula and Description1 A * is used when an HTTP request does not apply to a specific source, but to the same Server, and is only allowed when the method used is not necessarily applied to a source . For example:
OPTIONS * HTTP / 1.1
2 absoluteURI is used when an HTTP request is being created for a delegation. The requested delegation passes to the request or service from a valid cache, and returns the response. For example:GET http://www.w3.org/pub/WWW/TheProject.html HTTP / 1.1
3 The most common form of Request-URI is used to identify a source on an original Server or gateway. For example, a Client wishing to obtain a source directly from the original Server will create a TCP connection to port 80 of the host www.w3.org and send the following lines:GET /pub/WWW/TheProject.html HTTP / 1.1
Host: www.w3.org
Note that absolute transmission cannot be empty; If nothing is displayed in the original URI, it must be provided as "/" (Server root).
Required Header fields
We will learn General-Header and Entity-Header in a separate chapter when we will learn about Header fields. Now, let's see what the required Header fields are:
The Request-Header fields allow the Client to transmit additional information about the request, and to the Client itself, to the Server. These fields act as required editors. Below is a list of important Request-Header fields that can be used based on the request:
- Accept-Charset
- Accept-Encoding
- Accept-Language
- Authorization
- Expect
- From
- Host
- If-Match
- If-Modified-Since
- If-None-Match
- If-Range
- If-Unmodified-Since
- Max-Forwards
- Proxy-Authorization
- Range
- Referer
- TE
- User-Agent
You can create your own fields in case you are writing Client and Server for yourself.
Examples of Notice Required
Now we put all of the above learned together to create an HTTP request to instruct the hello.htm page from the Server running on tutorialspoint.com.
GET /hello.htm HTTP / 1.1
User-Agent: Mozilla / 4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Here we do not send any data requests to the Server because we are instructing a page that is plain HTML from the Server. The connection is General-Header, and the rest of the Header are the required Headers. The following example shows how to send sample data to the Server by using the required notification body:
POST /cgi-bin/process.cgi HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.com Content-Type: application/x-www-form-urlencoded Content-Length: length Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: Keep-Alive licenseID=string&content=string&/paramsXML=string
Here, the URl is provided with /cgi-bin/process.cgi that will be used to process the transmitted data and accordingly a response will be returned. Here content-type tells the Server that the transmitted data is a simple web form data and length will be the actual length of the data set in the notification body. The following example shows how you can pass pure XML to your Server.
POST /cgi-bin/process.cgi HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.com Content-Type: text/xml; charset=utf-8 Content-Length: length Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: Keep-Alive string
According to Tutorialspoint
Previous post: Message in HTTP
Next post: Feedback (Response) in HTTP
You should read it
Maybe you are interested
Clouds on Neptune may be created by the Sun The planet has the fastest wind in the solar system, reaching a speed of 2,400 km/h Foods that help increase memory 12 super foods you should have on the menu Review the Soundmax M2 bluetooth speaker Review speaker karaoke Microtek MTK - 04 _ great bluetooth speakers for events, karaoke bars