Date post: | 17-Jan-2016 |
Category: |
Documents |
Upload: | oswald-brooks |
View: | 218 times |
Download: | 0 times |
Operating SystemsOperating Systems
Lesson 12
HTTP vs HTMLHTTP vs HTML
HTML: hypertext markup language◦ Definitions of tags that are added to Web
documents to control their appearance
HTTP: hypertext transfer protocol◦ The rules governing the conversation
between a Web client and a Web server
HTMLHTML<html>
<body><h1>My First Heading</h1><p>My first paragraph.</p><img src="hackanm.gif" width="45“
height="45" /></body>
</html>
HTTPHTTP
•HTPP is a text-based protocol: uses text to represent its control messages
•HTTP is a asymmetric: there are a client and server
•HTTP is stateless: a session consist of single request/response pair
•HTTP servers usually listen to incoming TCP connection on port 80
URLURL
HTTP RequestHTTP Request
HTTP ResponseHTTP Response
HTTP request formatHTTP request format
Cr=‘\r’ lf=‘\n’
HTTP response formatHTTP response format
Static vs. Dynamically Static vs. Dynamically Generated HTML pagesGenerated HTML pages
Passing Parameters to the Passing Parameters to the Web ServerWeb Server
HTML:
<form name="input" action=“form.asp" method="get"> <input type="text" name="user" /> <input type="submit" value="Submit" /></form>
Browser:
HTTP Request:GET form.asp?user=tom HTTP/1.1
Common Gateway Interface(CGI) Standard for passing query parameters to the scripts/applications Parameters(query string) via environment variable
Submit
Some HTTP Request Some HTTP Request MethodsMethods
GET: retrieve information identified by the URL.
HEAD: retrieve meta-information about the URL
POST: send information to a URL and retrieve result.
HTTP 12
Response Status LineResponse Status LineHTTP-Version Status-Code Message
◦Status Code is 3 digit number (for computers) 1xx Informational 2xx Success 3xx Redirection 4xx Client Error 5xx Server Error
◦Message is text (for humans)
HTTP 13
Example Status LinesExample Status LinesHTTP/1.0 200 OK
HTTP/1.0 301 Moved Permanently
HTTP 1/0 304 Not Modified
HTTP/1.0 400 Bad Request
HTTP/1.0 500 Internal Server Error
HTTP 14
Some Request HeadersSome Request HeadersUser-Agent
◦Identification of the browser software
Accept◦MIME types that browser is ready to
accept
If-Modified-Since◦Date of cached reqource
Some Response HeadersSome Response HeadersContent-Type:
◦ Type of the returned content◦ MIME identifier◦ text/html, video/mpeg
Content-Length◦ Size of the content in bytes
Last-Modified◦ Date of last modification
Persistent ConnectionPersistent ConnectionHTTP 1.0 TCP connection is closed
after each request/response exchange
HTTP 1.1 allows keeping TCP connection for next request/response
Browser: request header◦Connection:Keep-Alive◦Default in HTTP 1.1
CookiesCookiesNeed a state over HTTPCookie Mechanism
◦Server instructs browser to keep a named value and send it back to the server along with next request
Cookie Expiration Policy◦Session cookie: forget cookie after
browser is closed◦Expiration time: forget after
prescribed time
Cookie HeadersCookie Headers Server (Response Header)
◦Set-Cookie: name_a=value
Client (request Header)
◦ Cookie: name_a=value; name_b=value