IT457
Primer on Computer
Networks
Week2_Lec1_HTTP
Application layer protocol defines:
• The types of messages exchanged,
• Request and response messages
• Syntax - message types,
• Fields and they are delineated
• Semantics - meaning of the information in the fields
• Rules
• When and how a process sends messages & responds to
HTTP
• The Web application
• document formats (that is, HTML)
• Web browsers (for example, Chrome and Microsoft Internet Explorer)
• Web servers (for example, Apache and Microsoft servers),
• Application-layer protocol
• The Web’s application-layer protocol – HTTP
• Defines the format and sequence of messages exchanged between browser and Web server.
Web and HTTP
First, a quick review…
▪ web page consists of objects, each of which can be stored on
different Web servers
▪ object can be HTML file, JPEG image, Java applet, audio file,…
▪ web page consists of base HTML-file which includes several
referenced objects, each addressable by a URL, e.g.,
[Link]/someDept/[Link]
host name path name
Application Layer: 2-4
HTTP is “stateless”
▪ server maintains no information about
HTTP overview past client requests
HTTP: hypertext transfer protocol
▪ Web’s application-layer protocol HT
▪ client/server model: PC running H
TP
que re
st
TTP
• client: browser that requests, Firefox browser res
pon
se
receives, (using HTTP protocol) and
“displays” Web objects e st
r equ
• server: Web server sends (using TP nse server running
HT po Apache Web
r es
HTTP protocol) objects in response HT
T P
server
to requests
iPhone running
Safari browser
Application Layer: 2-5
HTTP connections: two types
Non-persistent HTTP Persistent HTTP
1. TCP connection opened ▪TCP connection opened to
2. at most one object sent a server
over TCP connection ▪multiple objects can be
3. TCP connection closed sent over single TCP
connection between client,
downloading multiple and that server
objects required multiple ▪TCP connection closed
connections
Application Layer: 2-6
Non-persistent HTTP: example
User enters URL: [Link]/someDepartment/[Link]
(containing text, references to 10 jpeg images)
1a. HTTP client initiates TCP
connection to HTTP server 1b. HTTP server at host
(process) at [Link] on [Link] waiting for TCP
port 80 connection at port 80 “accepts”
connection, notifying client
2. HTTP client sends HTTP
request message (containing
URL) into TCP connection 3. HTTP server receives request message,
socket. Message indicates forms response message containing
time that client wants object requested object, and sends message
someDepartment/[Link] into its socket
Application Layer: 2-7
Non-persistent HTTP: example (cont.)
User enters URL: [Link]/someDepartment/[Link]
(containing text, references to 10 jpeg images)
4. HTTP server closes TCP
5. HTTP client receives response connection.
message containing html file,
displays html. Parsing html file,
finds 10 referenced jpeg objects
6. Steps 1-5 repeated for
each of 10 jpeg objects
time
Application Layer: 2-8
Non-persistent HTTP: response time
RTT (definition): time for a small
packet to travel from client to initiate TCP
server and back connection
RTT
HTTP response time (per object):
▪ one RTT to initiate TCP connection request file
▪ one RTT for HTTP request and first few RTT time to
transmit
bytes of HTTP response to return file
file received
▪ object/file transmission time
time time
Non-persistent HTTP response time = 2RTT+ file transmission time
Application Layer: 2-9
HTTP request message
▪ two types of HTTP messages: request, response
▪ HTTP request message:
• ASCII (human-readable format)
carriage return character
line-feed character
request line (GET, POST,
GET /[Link] HTTP/1.1\r\n
HEAD commands) Host: [Link]\r\n
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X
10.15; rv:80.0) Gecko/20100101 Firefox/80.0 \r\n
header Accept: text/html,application/xhtml+xml\r\n
lines Accept-Language: en-us,en;q=0.5\r\n
Accept-Encoding: gzip,deflate\r\n
Connection: keep-alive\r\n
\r\n
carriage return, line feed
at start of line indicates
end of header lines * Check out the online interactive exercises for more
examples: [Link] Application Layer: 2-10
HTTP request message: general format
method sp URL sp version cr lf request
line
header field name value cr lf
header
~
~ ~
~ lines
header field name value cr lf
cr lf
~
~ entity body ~
~ body
Application Layer: 2-11
Other HTTP request messages
POST method: HEAD method:
▪ web page often includes form ▪ requests headers (only) that
input would be returned if specified
▪ user input sent from client to URL were requested with an
server in entity body of HTTP HTTP GET method.
POST request message
PUT method:
▪ uploads new file (object) to server
GET method (for sending data to server): ▪ completely replaces file that exists
▪ include user data in URL field of HTTP at specified URL with content in
GET request message (following a ‘?’): entity body of POST HTTP request
[Link]/animalsearch?monkeys&banana
message
Application Layer: 2-12
HTTP response message
status line (protocol HTTP/1.1 200 OK
status code status phrase) Date: Tue, 08 Sep 2020 [Link] GMT
Server: Apache/2.4.6 (CentOS)
OpenSSL/1.0.2k-fips PHP/7.4.9
mod_perl/2.0.11 Perl/v5.16.3
header Last-Modified: Tue, 01 Mar 2016 [Link] GMT
lines ETag: "a5b-52d015789ee9e"
Accept-Ranges: bytes
Content-Length: 2651
Content-Type: text/html; charset=UTF-8
\r\n
data, e.g., requested data data data data data ...
HTML file
* Check out the online interactive exercises for more examples: [Link]
Application Layer: 2-13
HTTP response status codes
▪ status code appears in 1st line in server-to-client response message.
▪ some sample codes:
200 OK
• request succeeded, requested object later in this message
301 Moved Permanently
• requested object moved, new location specified later in this message (in
Location: field)
400 Bad Request
• request msg not understood by server
404 Not Found
• requested document not found on this server
505 HTTP Version Not Supported
Application Layer: 2-14