Network-2-Web and HTTP
Web and HTTP
web page consists of objects
object can be HTML file, JPEG image, Java applet, audio file, …
web page consists of base HTML-file which includes several referenced objects
each object is addressable by a URL, e.g.,
HTTP overview
HTTP: hypertext transfer protocol
- Web’s application layer protocol
- client/server model
- client: browser that requests, revceives, (using HTTP protocol) and displays Web objects
- server: Web server sends (using HTTP protocol) objects in response to requests
- uses TCP
- client initiates TCP connection(creates socket) to server, port 80
- server accepts TCP connection from client
- HTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server)
- TCP connection closed
- HTTP is “stateless”
- server maintains no information about past client requests
- aside :
protocols that maintain "state" are complex!
- past history (state) must be maintained
- if server/client crashes, their views of “state” may be inconsistent, must be reconciled
HTTP connections
- non-persistent HTTP
- at most one object sent over TCP connection
- connection then closed
- downloading multiple obejcts requires multiple connections
- at most one object sent over TCP connection
- persistent HTTP
- multiple objects can be sent over single TCP connection between client, server
Non-persistent HTTP
suppose user enters URL:
www.someSchool.edu/someDepartment/home.index
Non-persistent HTTP: response time
- RTT (definition): time for a small packet to travel from client to server and back
- HTTP response time
- one RTT to initiate TCP connection
- one RTT for HTTP request and first few bytes of HTTP response to return
- file transmission time
- non-persistent HTTP response time = 2RTT + file transmission time
Persistent HTTP
- non-persistent HTTP issues
- requires 2 RTTs per object
- browsers often open parallel TCP connections to fetch referenced objects
- OS overhead for each TCP connection (each tcp buffer, socket)
- persistent HTTP
- server leaves connection open after sending response
- subsequent HTTP messages between same client/server sent over open connection
- client sends request as soon as it encounters a referenced object
- as little as one RTT for all the referenced objects
HTTP request message
- two types of HTTP messages: request, response
- HTTP request message
- ASCII (human-readable format)
Keep-Alive Header is persistent HTTP configure
general format
Uploading form input
- POST method:
- web page often includes form input
- input is uploaded to server in entity body
- URL methoed:
- uses GET method
- input is uploaded in URL field of request line
Method types
- HTTP/1.0
- GET
- POST
- HEAD
- asks server to leave requested object out of response
- HTTP/1.1
- GET, POST, HEAD
- PUT
- uploads file in entity body to path specified in URL field
- DELETE
- deletes file specified in the URL field
HTTP response message
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 msg
- 301 Moved Permanently
- request object moved, new location specified later in this msg (Location Header)
- 400 Bad Request
- request msg not understood by server
- 404 Not Found
- requested document not found on this server
- 505 HTTP Version Not Supported
- 200 OK
User-server state: cookies
- many Web sites use cookies four components
- cookie header line of HTTP response message
- cookie header line in next HTTP request message
- cookie file kept on user’s host, managed by user’s browser
- back-end database at Web site
- example
- Susan always access Internet from PC
- visits specific e-commerce site for first time
- when initial HTTP requests arrives at site, site creates
- unique ID
- entry in backend database for ID
- what cookies can be used for
- authorization
- shopping carts
- recommendations
- user session state (Web e-mail)
- how to keep “state”
- protocol endpoint: maintain stat at sender/receiver over multiple transactions
- cookies: http messages carry state
- aside : cookies and privacy
- cookies permit sites to learn a lot about you
- you may supply name and e-amil to sites
Web caches (proxy server)
goal
: satisfy client request with out involving origin server- user sets browser: Web access via cache
- browser sends all HTTP requests to cache
- object in cache: cache returns object
- else cache requets object from origin server, then returns object to client
- cache acts as both client and server
- server for original requesting client
- client to origin server
- typically cache is installed by ISP (university, company, residential ISP)
- why Web cacing?
- reduce response time for cient request
- reduce traffic on an institution’s access link
- Internet dense with caches: enables “poor” content providers to effectively deliver content (so Too does P2P file sharing)
Conditional GET
Goal
: don’t send object if cache has up-to-date cached version- reduce delay
- lower link utilization
- cache: specify date of cached copy in HTTP request
- If-modified-since: date
- server response contatins no object if cached copy is up-to-date
- HTTP/1.0 304 Not Modified
참조
- 컴퓨터 네트워크 이미정 교수님 강의
- Computer Networking: A Top-Down Approach Featuring the Internet