What is HTTP?
HTTP Request and Response
- A client a browser sends an HTTP request to the web.
- A web server receives the request.
- The server runs an application to process the request.
- The server returns an HTTP response (output) to the browser.
- The client (the browser) receives the response.
Request Method
Method | Description |
---|---|
GET | GET is used to retrieve information from the given server using a given URI. |
HEAD | HEAD is the Same as GET, but it transfers the status in line, and the header section only. |
POST | POST is used for the request to send data to the server. Such as associate/ customer information, document upload, and much more. using HTML forms. |
PUT | PUT is used for Replaces all the current representations of the data resource with the uploaded content. |
DELETE | DELETE is used for Removes all the current representations of the data resource given by URI. |
CONNECT | CONNECT is used for establishes a tunnel to the server identified by a given URI. |
OPTIONS | OPTIONS is used for describing the communication options for the data resource. |
TRACE | TRACE is used for a message loop backtest along with the path to the data resource. |
Request-URI
Request-URI = "*" | absoluteURI | abs_path | authority
S.N. | Method and Description |
---|---|
1 | The asterisk * is used when an HTTP request does not apply to a particular resource, but to the server itself, and is only allowed when the method used does not necessarily apply to a resource. Such as: OPTIONS * HTTP/1.1 |
2 | The absoluteURI is used when an HTTP request is being made to a proxy. The proxy is requested to forward the request or service from a valid cache and return the response. Such as: GET http://www.w3.org/pub/WWW/TitleofProject.html HTTP/1.1 |
3 | The most common form of Request-URI is used to identify a resource on an origin server or gateway. Such as: a client wishing to retrieve a resource directly from the origin server would create a TCP connection to port 80 of the host "www.w3.org" and send the following lines: GET /pub/WWW/TitleofProject.html HTTP/1.1 Host: www.w3.org Note:- Absolute path cannot be empty; if none is present in the original URI, it MUST be given as "/" (the server root). |
Examples of Request Message
Examples of Response Message
The HTTP Request Circle
- The browser requests an HTML page. The server returns an HTML file.
- The browser requests a style sheet. The server returns a CSS file.
- The browser requests a JPG image. The server returns a JPG file.
- The browser requests JavaScript code. The server returns a JS file
- The browser requests data. The server returns data (in XML or JSON).
XHR - XML Http Request
- XHR is used for a JavaScript object that is used to data transfer between a web browser and a web server.
- XHR is used for request and receive data for the purpose of modifying a web page.
XHR Object is a Website Developers Dream because:
- Update a web page without reloading the page
- Send data to a server - in the background
- Receive data from a server - after the page has loaded
- Request data from a server - after the page has loaded