an introduction to http

31
Hypertext Transport Protocol Keerthana Krishnan C6A, Rl : 35

Upload: keerthana-krishnan

Post on 19-Jul-2015

123 views

Category:

Technology


2 download

TRANSCRIPT

Hypertext Transport Protocol

Keerthana Krishnan

C6A, Rl : 35

What is a protocol?

•In diplomatic circles, a protocol is the set of rules governing a conversation between people

•We have seen that the client and server carry on a machine-to-machine conversation

•A network protocol is the set of rules governing a conversation between a client and a server

•There are many protocols, HTTP is just one

Development

The standards development of HTTP was coordinated by

the Internet Engineering Task Force (IETF) and the World

Wide Web Consortium (W3C), culminating in the

publication of a series of Requests for Comments

(RFCs)

RFC 2616 (June 1999) defined HTTP/1.1, the version of

HTTP most commonly used today.

In June 2014, RFC 2616 was retired and HTTP/1.1 was

redefined by new RFCs 7230-7235.

HTTP/2 is currently in draft form.

The TCP/IP protocol layers

Application

Transport

Internet

Data link

Physical

Get useful work done – retrieve Web pages, copy

files, send and receive email, etc.

Make client-server connections and optionally

control transmission speed, check for errors, etc.

Route packets between networks

Route data packets within the local area network

Specify what medium connects two nodes, how

binary ones and zeros are differentiated, etc,

The application program is king – it gets work done using the lower level

layers for communication between the client and server.

The application layer is boss – the top layer

•Your boss says: Send this package to Miami -- I don't care if you use Federal Express, UPS, or any other means. Also, let me know when it arrives or if it cannot be delivered for some reason.

•The application program says: Send this request to the server -- I don't care how you do it or whether it goes over phone lines, radio, or anything else about the details. Just send the message, and let me know when it arrives or if it cannot be delivered for some reason.

Layer Function

Application Do useful work like Web browsing, email, and file transfer

Lower layers Handle communication between the client and server

There are five TCP/IP layers, the application layer and four lower layers.

HTTP is an application layer protocol

•The Web client and the Web server are application programs•Application layer programs do useful work like retrieving Web pages, sending and receiving email or transferring files•Lower layers take care of the communication details•The client and server send messages and data without knowing anything about the communication network

Computer Port

l A port is an application-specific or process-specific

software construct serving as a communications endpoint

in a computer's host operating system.

lThe purpose of ports is to uniquely identify different

applications or processes running on a single computer

and thereby enable them to share a single physical

connection to a packet-switched network like the Internet.

lA port is associated with an IP address of the host, as

well as the type of protocol used for communication.

l A port is identified for each address and protocol by a

16-bit number, commonly known as the port number.

HTTP : Hypertext Transfer Protocol

The Hypertext Transfer Protocol (HTTP) is an

application protocol for distributed, collaborative,

hypermedia information systems.

HTTP is the foundation of data communication for

the World Wide Web.

Hypertext is structured text that uses logical links

(hyperlinks) between nodes containing text. HTTP

is the protocol to exchange or transfer hypertext

•I would like to open a connection

•GET <file location>

•Display response•Close connection

•OK

•Send page or error message

•OK

Client Server

HTTP is the set of rules governing the format and content of the

conversation between a Web client and server

An HTTP conversation

Persistant Connection

lHTTP persistent connection, also called HTTP

keep-alive, or HTTP connection reuse, is the idea

of using a single TCP connection to send and

receive multiple HTTP requests/responses, as

opposed to opening a new connection for every

single request/response pair.

lThe newer SPDY protocol uses the same idea

and takes it further to allow multiple concurrent

requests/responses to be multiplexed over a

single connection.

lIt is a feature for HTTP 1.1, allowing to pipeline

requests

An HTTP Session

l An HTTP client initiates a request by establishing

a Transmission Control Protocol (TCP) connection

to a particular port on a server (typically port 80,

occasionally port 8080

l An HTTP server listening on that port waits for a

client's request message.

lUpon receiving the request, the server sends

back a status line, such as "HTTP/1.1 200 OK",

and a message of its own.

lThe body of this message is typically the

requested resource, although an error message or

other information may also be returned

HTTP Methods

HTTP defines methods to indicate the desired action to

be performed on the identified resource.

Main Methods

GETlretrieve a URL from the serverlsimple page request

lrun a CGI program

lrun a CGI with arguments attached to the URL

POSTlpreferred method for forms processing

lrun a CGI program

lparameterized data in system

lmore secure and private

PUTlUsed to transfer a file from the client to the server

HTTP Status codes Part I

HTTP Status codes (continued)

HTTP Headers

lHTTP header fields are components of the header

section of request and response messages in the

Hypertext Transfer Protocol (HTTP).

lThey define the operating parameters of an HTTP

transaction.

lThe header fields are transmitted after the request or

response line, which is the first line of a message.

lHeader fields are colon-separated name-value pairs in

clear-text string format, terminated by a carriage return

(CR) and line feed (LF) character sequence.

lThe end of the header section is indicated by an empty

field, resulting in the transmission of two consecutive CR-

LF pairs.

Table 27.3 General headers

Table 27.4 Request headers

Table 27.5 Response headers

Table 27.6 Entity headers

Figure 27.15 Header format

This example retrieves a document. We use the GET

method to retrieve an image with the path

/usr/bin/image1. The request line shows the method

(GET), the URL, and the HTTP version (1.1). The header

has two lines that show that the client can accept

images in the GIF or JPEG format. The request does not

have a body. The response message contains the

status line and four lines of header. The header lines

define the date, server, MIME version, and length of the

document. The body of the document follows the

header (see Figure 27.16).

Example 27.1

Figure 27.16 Example 27.1

In this example, the client wants to send data to the

server. We use the POST method. The request line

shows the method (POST), URL, and HTTP version

(1.1). There are four lines of headers. The request body

contains the input information. The response message

contains the status line and four lines of headers. The

created document, which is a CGI document, is

included as the body (see Figure 27.17).

Example 27.2

Figure 27.17 Example 27.2

Telnet

lTelnet is a network protocol used on the Internet or local area networks to provide a bidirectional interactive text-oriented communication facility using a virtual terminal connection.

lUser data is interspersed in-band with Telnet control information in an 8-bit byte oriented data connection over the Transmission Control Protocol (TCP).

lTelnet provided access to a command-line interface (usually, of an operating system) on a remote host.

lMost network equipment and operating systems with a TCP/IP stack support a Telnet service for remote configuration (including systems based on Windows NT).

lHowever, because of serious security issues when using Telnet over an open network such as the Internet, its use for this purpose has waned significantly in favor of SSH.

HTTP uses ASCII characters. A client can directly

connect to a server using TELNET, which logs into port

80 (see next slide). The next three lines show that the

connection is successful. We then type three lines. The

first shows the request line (GET method), the second

is the header (defining the host), the third is a blank,

terminating the request. The server response is seven

lines starting with the status line. The blank line at the

end terminates the server response. The file of 14,230

lines is received after the blank line (not shown here).

The last line is the output by the client.

Example 27.3

Example 27.3 (continued)

More about Telnet

lConnect to other servers through telnet to view their animated ASCII art, games, etc they offer the public.

lMore details at : http://mewbies.com/acute_terminal_fun_telnet_public_servers_watch_star_wars_play_games_etc.htm

References

PPT on HTTP available at :

bpastudio.csudh.edu/fac/lpress/presentations/http/

http.ppt

Chapter 27, WWW and HTTP from the Fourth

Edition of "Data Communications and

Networking", by A. Behrouz Forouzan, Tata

McGraw-Hill Education, 2006