What is HTTP

 What is HTTP?

HTTP stands for (HyperText Transfer Protocol). WWW is a communication between web clients and servers. Communication between client computers and web servers is done by sending HTTP requests and receiving HTTP Responses. Servers are most often computers in the cloud. The World Wide Web is about communication between web clients and web serversClients are often browsers (Chrome, Edge, Safari), but they can be any type of program or device.

HTTP Request and Response

  1. A client a browser sends an HTTP request to the web.
  2. A web server receives the request.
  3. The server runs an application to process the request.
  4. The server returns an HTTP response (output) to the browser.
  5. The client (the browser) receives the response.

Request Method

The request method indicates the method to be performed on the resource identified by the given Request-URI.


MethodDescription
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 is a Uniform Resource Identifier and identifies the resource upon which to apply the request.

Request-URI = "*" | absoluteURI | abs_path | authority


S.N.Method and Description
1The 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

2The 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

3The 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

HTTP request to fetch wctutorial.htm page from the web server running on wctutorial.com


The connection is a general-header, and the rest of the headers are request headers.


Given URL  /cgi-bin/process.cgi will be used to process the passed data and accordingly, a response will be returned. content-type tells the server that the passed data is a simple web form data and length will be the actual length of the data put in the message body.



Examples of Response Message


HTTP response for a request to fetch the hello.htm page from the web server running on tutorialspoint.com




When shows an HTTP response message displaying error condition when the web server could not find the requested page:




HTTP response message showing error condition when the webserver encountered a wrong HTTP version in the given HTTP request:




The HTTP Request Circle

  1. The browser requests an HTML page. The server returns an HTML file.
  2. The browser requests a style sheet. The server returns a CSS file.
  3. The browser requests a JPG image. The server returns a JPG file.
  4. The browser requests JavaScript code. The server returns a JS file
  5. 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

Post a Comment

Post a Comment (0)

Previous Course Next Course