0% found this document useful (0 votes)
19 views

Intro To Hypertext Transfer Protocol (HTTP)

The document provides an overview of the Hypertext Transfer Protocol (HTTP) by explaining the client request process, server response process, common HTTP methods and status codes. A client request consists of the HTTP method, URI, protocol version and optional headers. A server response includes a status line indicating success or failure, response headers with metadata, and the requested content. Common methods are GET, POST, PUT and DELETE while common status codes include 200 for success, 301 for permanent redirect, 404 for not found and 500 for server error.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Intro To Hypertext Transfer Protocol (HTTP)

The document provides an overview of the Hypertext Transfer Protocol (HTTP) by explaining the client request process, server response process, common HTTP methods and status codes. A client request consists of the HTTP method, URI, protocol version and optional headers. A server response includes a status line indicating success or failure, response headers with metadata, and the requested content. Common methods are GET, POST, PUT and DELETE while common status codes include 200 for success, 301 for permanent redirect, 404 for not found and 500 for server error.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

QAFQAZ UNIVERSITY

Intro to HyperText
Transfer Protocol (HTTP)
Dr. Abzetdin ADAMOV
Overview of HTTP

• HTTP defines a simple request-response


language
• A web client establishes a connection with
a web server by using HTTP
• HTTP defines how to correctly phrase the
request and how the response should look
like
Note: HTTP does not define how the network connection is made or
managed, nor how the information is actually transmitted; it is done by
the lower-level protocols such as TCP/IP
The Client Request

An HTTP request consists of the following:

1. The method, which must be one of a set of


legal action
2. The Universal Resource Identifier (URI), which
is the name of the information request
3. The protocol version
4. Optional supplemental information
HTTP methods
Method Action
Return the object; that is, retrieve the
GET information
Return only information about the object, such
HEAD as how old it is, but not the object itself
Send information to be stored on the server.
POST Many servers do not allow information to be
POSTed except as input to scripts
Send a new copy of an existing object to the
PUT server. Many servers do not allow documents to
be PUT.
Permanently delete the object. Like PUT, this
DELETE method is not allowed by most servers
Example of Client Request
For example, to request the document /network/index.htm from
http://www.qafqaz.edu.az/, the web client will send the following
request:

GET /network/index.htm HTTP/1.0


User-Agent: NCSA Mosaic for Windows 95/3.0
Accept: text/plain
Accept: text/html
Accept: application/postscript
Accept: image/gif
The Server Response

An HTTP response consist of the following:

1. A status line, which indicates the success or


failure of the request
2. A description of the information in the
response. This is the metadata or
metainformation
3. The actual information requested
Status Line
The status line has the form:

Field Description
HTTP-version The version of the HTTP
Number indicates the result of the
Status-code
request

A short phrase that explains what


Reason
the number means

Indicates to the browser what it


Metadata (Metainformation) must know to interpret and
display the information
Selected HTTP status code
Code Reason Description
The request succeeded. The information requested
200 Document follows
follows.
301 Moved Permanently The document has moved to a new URL
302 Moved Temporarily The document has moved temporarily to a new URL
The document has not been modified since the date
304 Not Modified specified in a GET request with if-modified-
since.
The information could not be found or permission
404 Not Found was denied. This error is returned if the
requested URL does not exist or was misspelled
The information is restricted; please retry with
401 Unauthorized
proper authentication.
The information requires paying a fee; please retry
402 Payment Required
with proper payment (not used often)
403 Forbidden Access is forbidden
500 Server Error The server experienced an error
Description of Information

Field Description
The type of server software providing the
Server
response
Date The date and time of the response
Content-Length How many bytes of data will be sent to the client

The MIME type of the information being returned,


Content-Type
such as HTML or an image

The language of the information, such as English


Content-Language
or French
Content-Encoded Additional encoding, such as data compression
The date and time that the information was most
Last-Modified
recently modified
Example of Server Response
For example, the response for the /network/index.htm request
might be the following:

HTTP/1.0 Status 200 Document follows


Server: NCSA/2.0
Date: Wed, 23 Jun, 1999 18:08:08 GMT
Content-type: text/html
Content-length: 5800
Last-modified: Tue, 22 Jun, 1999 12:00:00 GMT
HTTP Details
What’s the difference between GET and POST?

<FORM
ACTION=application_url
METHOD= GET or POST
ENCTYPE= application/x-www-form-urlencoded or
multipart/form-data
>
Form Elements
</FORM>
Serving a Web Document form a Web Server
The httpd waits for a request to arrive from a web client in the Internet

Step 1: Loop and Wait for a new request


Serving a Web Document form a Web Server

Step 2: A Request arrives from a Web Client


Serving a Web Document form a Web Server
The Web Server parses and understand the request is a GET for information.

Step 3: The Request is Parsed by the Web Server


Serving a Web Document form a Web Server

The web server now understnad the protocol version is 1.0. It is a Netscape
browser for NT, etc. Since this is a normal example, no further action is
needed.

Step 4: Parses the Rest of the Header


Serving a Web Document form a Web Server
The httpd in this stage will fulfills the request or send back error messages. In
this example, web server will search in the file system for /index.htm.

Success: The document is sent

Step 5: Do the method requested


Serving a Web Document form a Web Server
Failure: An error such as the following will be sent:

Step 5: Failure: An error such as the following will be sent


Serving a Web Document form a Web Server

Step 6: Finish up: close the file; close the network connection

Close file and connection (socket).

Client will then due with the data received.


 
Step 7: Back to Step 1 and Loop and Wait

You might also like