HTTP
Derek Bridge
Department of Computer Science,
University College Cork
HTTP
Aims:
- to know a little about simple HTTP requests that request (static) web pages
- to see where DNS fits in
The Web is a client-server application
- Web client computers
- run web client software (e.g. browsers)
- the software make requests for web resources (e.g. HTML files, CSS files,
image files, ...)
- Web server computers
- host web resources (text files, graphics files, programs,...)
- run web server software that responds to requests
Ports
- One server might be offering ('hosting') more than one service
- E.g. a server computer may be running web server software and email server software
- How does a client indicate which
server program is to handle its requests?
- Each server program is assigned an identification number, called
a port number
Listening on ports
What your browser does when you enter a URL or click on a link...
- If it needs to request a new web page, your browser works out:
- the scheme (which usually defaults to http)
- the server name (e.g. www.rte.ie)
- the port number (which defaults to 80)
- the pathname of the file you want (e.g. /news/index.html)
- Your browser must now send a request to the web server, asking for this file
- Question: There are times when your browser doesn't need to do this.
Give an example
- The request (and the server's response) must be formulated according to a
communications protocol (in this case, HTTP)
HTTP requests
- Request line (required): command (method), URL and HTTP version number
- Request header lines (largely optional): info about date, browser,...
- Request message body (optional): empty for most commands (methods)
Example HTTP request from The TCP/IP Guide by Charles M. Kozierok
HTTP responses
- Status line (optional): HTTP version number, status code, short explanation of code
- Response header lines (optional): info about date, server,...
- Response message body (required): the requested resource (web page, image,...)
Example HTTP response from The TCP/IP Guide by Charles M. Kozierok
HTTP response status codes
- 1XX: Informational (used in 1.1):
- e.g. 100 Continue, 101 Switching Protocols
- 2XX: Success:
- e.g. 200 OK, 206 Partial Content
- 3XX: Redirection:
- e.g. 301 Moved Permanently, 304 Not Modified
- 4XX: Client error:
- e.g. 400 Bad Request, 403 Forbidden, 404 Not Found
- 5XX: Server error:
- e.g. 500 Internal Server Error, 503 Service Unavailable
DNS
- Prior to sending the HTTP request, your browser needs to convert from server name to server IP address
Embedded content
- Suppose the web page contains embedded content (e.g. stylesheets, images)
- The server does not send all the content in one go
- The client receives the web page and then sends separate requests for the embedded content