Upload
hasan-pehlivanlar
View
218
Download
7
Embed Size (px)
Citation preview
8/7/2019 Introduction 2 HTTP
1/18
Intro to HyperTextTransfer Protocol (HTTP)Intro to HyperTextTransfer Protocol (HTTP)
Dr. Abzetdin ADAMOV
QAFQAZ UNIVERSITYQAFQAZ UNIVERSITY
8/7/2019 Introduction 2 HTTP
2/18
Overview of HTTPOverview of HTTP
HTTP defines a simple request-response
language
A web client establishes a connection witha 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
8/7/2019 Introduction 2 HTTP
3/18
The Client RequestThe Client Request
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 version4. Optional supplemental information
An HTTP request consists of the following:
8/7/2019 Introduction 2 HTTP
4/18
HTTP methodsHTTP methods
Method Action
GETReturn the object; that is, retrieve the
information
HEADReturn only information about the object, such
as how old it is, but not the object itself
POSTSend information to be stored on the server.
Many servers do not allow information to be
POSTed except as input to scripts
PUTSend a new copy of an existing object to the
server. Many servers do not allow documents to
be PUT.
DELETEPermanently delete the object. Like PUT, this
method is not allowed by most servers
8/7/2019 Introduction 2 HTTP
5/18
Example of Client RequestExample 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
8/7/2019 Introduction 2 HTTP
6/18
The Server ResponseThe Server Response
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
An HTTP response consist of the following:
8/7/2019 Introduction 2 HTTP
7/18
8/7/2019 Introduction 2 HTTP
8/18
Selected HTTP status codeSelected HTTP status code
Code Reason Description
200 Document followsThe request succeeded. The information requested
follows.
301 Moved Permanently The document has moved to a new URL
302 Moved Temporarily The document has moved temporarily to a new URL
304 Not ModifiedThe document has not been modified since the date
specified in a GET request with if-modified-
since.
404 Not FoundThe information could not be found or permission
was denied. This error is returned if the
requested URL does not exist or was misspelled
401 Unauthorized The information is restricted; please retry withproper authentication.
402 Payment RequiredThe information requires paying a fee; please retry
with proper payment (not used often)
403 Forbidden Access is forbidden
500Server Error The server experienced an error
8/7/2019 Introduction 2 HTTP
9/18
Description of InformationDescription of Information
Field Description
ServerThe type of server software providing the
response
Date The date and time of the responseContent-Length How many bytes of data will be sent to the client
Content-TypeThe MIME type of the information being returned,
such as HTML or an image
Content-Language The language of the information, such as Englishor French
Content-Encoded Additional encoding, such as data compression
Last-ModifiedThe date and time that the information was most
recently modified
8/7/2019 Introduction 2 HTTP
10/18
Example of Server ResponseExample of Server Response
For example, the response for the /network/index.htm request
might be the following:
HTTP/1.0 Status 200Document follows
Server: NCSA/2.0Date: 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
8/7/2019 Introduction 2 HTTP
11/18
HTTP DetailsHTTP Details
Whats the difference between GET and POST?
Form Elements
8/7/2019 Introduction 2 HTTP
12/18
8/7/2019 Introduction 2 HTTP
13/18
Step 2: A Request arrives from a Web Client
Serving a Web Document form a Web Server
8/7/2019 Introduction 2 HTTP
14/18
Step 3: The Request is Parsed by the Web Server
Serving a Web Document form a Web Server
The Web Server parses and understand the request is a GET for information.
8/7/2019 Introduction 2 HTTP
15/18
Step 4: Parses the Rest of the Header
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.
Serving a Web Document form a Web Server
8/7/2019 Introduction 2 HTTP
16/18
Step 5: Do the method requested
Serving a Web Document form a Web ServerThe 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
8/7/2019 Introduction 2 HTTP
17/18
Step 5: Failure: An error such as the following will be sent
Serving a Web Document form a Web Server
Failure: An error such as the following will be sent:
8/7/2019 Introduction 2 HTTP
18/18
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
Serving a Web Document form a Web Server