Web Engineering: Anup Majumder Lecturer, CSE, DIU
Web Engineering: Anup Majumder Lecturer, CSE, DIU
HTTP Protocol
Anup Majumder
Lecturer, CSE, DIU
Internet and Web
HTML tells the browser how to present the
content to the user.
Web and HyperText Transfer Protocol (HTTP)
file,…
Web page consists of base HTML-file which includes several
referenced objects
Each object is addressable by a URL
Example URL:
www.someschool.edu/someDept/pic.gif
path name
host name
URL
HTTP overview
Mac running
Navigator
Ports
connection request
file
one RTT for HTTP request time to
RTT
transmit
and first few bytes of HTTP file
file
response to return received
file transmission time
time time
total = 2RTT+transmit time
Persistent HTTP
request line
(GET, POST, GET /somedir/page.html HTTP/1.1
HEAD commands) Host: www.someschool.edu
User-agent: Mozilla/4.0
header Connection: close
lines Accept-language:fr
Now let's look at the header lines in the example. The header line HOST: www.someschool.edu specifies the host on which the
object resides. You night think that this header line is unnecessary, as there is already a TCP connection in place to the host. But,
as we'll see in Section 2.2.6, the information provided by the host header line is required by Web proxy caches. By including
theConnection:close header line, the browser is telling the server that it doesn't want to use persistent connections; it wants the
server to close the connection after sending the requested object. Thus the browser that generated this request message
implements HTTP/1.1 but it doesn't want to bother with persistent connections. The User-agent: header line specifies the user
agent, that is, the browser type that is making the request to the server . Here the user agent is Mozilla/4.0, a Netscape browser.
This header line is useful because the server can actually send different versions of the same object to different types of user
agents. (Each of the versions is addressed by the same URL.) Finally, the Accept-language: header indicates that the user prefers
to receive a French version of the object, if such an object exists on the server; otherwise, the server should send its default
version.
The Entity Body is not used with the GET method, but is used with the POST method. The HTTP client uses the POST method
when the user fills out a form
Method types
HTTP/1.1
HTTP/1.0
GET,
GET POST, HEAD
PUT
POST
uploads file in entity body to path specified in URL field
HEAD
DELETE
asks server to leave requested object out of response
200 OK
request succeeded, requested object later in this message
301 Moved Permanently
requested object moved, new location specified later in this message
(Location:)
400 Bad Request
request message not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
User-Server Interaction: Authorization and Cookies
Authorization :
1) Provide username and password to access documents on server
2) Status code 401: Authorization Required
User-server state: cookies
Example:
Many major Web sites use cookies
Susan access Internet always from same PC
Four components:
1) She visits a specific
line ine-commerce site for first time
cookie header the HTTP response message
When initial HTTP requests arrives at site, site creates a unique ID and
2) cookie header line in HTTP request message
creates an entry in backend database for ID
3) cookie file kept on user’s host and managed by user’s browser
4) back-end database at Web site
Cookies: keeping “state” (cont.)
client server
Cookie file
usual http request msg
amazon: 1678 cookie: 1678 cookie- ss
ebay: 8734 specific acce
usual http response msg action
s
one week later:
s
ce
ac
Cookie file usual http request msg
cookie-
amazon: 1678
cookie: 1678
spectific
ebay: 8734 usual http response msg action
Cookies (continued)
aside
Cookies and privacy:
What cookies can bring: cookies permit sites to learn a lot about you
you may supply name and e-mail to sites
authorization
search engines use redirection & cookies to
learn yet more
advertising companies obtain info across sites
shopping carts
recommendations
mail)
Thank you