Download presentation
Presentation is loading. Please wait.
1
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland University
2
What is HTTP? Hypertext Transfer Protocol Language used to describe how documents are sent over the internet Rules by which browsers make requests and servers supply responses Includes ways to: Ask for a document by name Agree on data format Determine who the user is Decide how to handle outdated resources Indicate the results of the request When specifying a URL or clicking on a hyperlink, the browser translates into HTTP commands The server finds the resource and sends it back
3
HTTP Request Model HTTP is a stateless request/response protocol Client opens a socket to the Web server’s HTTP port (80 by default) Client sends a ASCII text request line, followed by zero or more HTTP headers, an empty line, and any data that accompanies the request The web server parses the request and locates the specified resource Server writes a copy of the resource to the socket, where it is read by the client The server closes connection Once the connection is closed, the server doesn’t remember anything about this request
4
Connecting to the Web Server Web server operates by listening for requests on a particular port (default port 80) If the server is running on any other port, it has to be part of the URL E.g. http://www.mycompany.com:4311/myfile.htmhttp://www.mycompany.com:4311/myfile.htm Client initiates an HTTP request by opening a TCP/IP socket to the Web server port, and then opening input and output stream over the socket Parameters required to open the socket are the Web server host name, and the port number Server host name is extracted from the URL Output stream used to send commands to server Input stream used to read the server response
5
Sending the HTTP Request Once the socket connection is made, Web browser writes an HTTP command to request the document A request has up to four parts: First part is “request line” Second part – one or more request headers Third part – Empty line consisting of carriage return or line feed Fourth part – User data
6
Part I - Request Line Mandatory part of HTTP Request Consists of three tokens, separated by spaces First Token: Request method Second Token: request URI (derived from the URL – stuff that comes after the host name) http://www.mycompany.com/myfile.html Third Token: HTTP version the client understands (allowable values are HTTP/1.0 and HTTP/1.1) Example of Request line: GET /myfile.html HTTP/1.0 There are eight possible methods defined in HTTP (GET and POST are the most frequently used)
7
Request Methods GET – A simple request to retrieve the resource identified in the URI HEAD – Same as GET, except the server doesn’t return the requested document. The server only returns the status line and headers POST – A request for the server to accept data that will be written to the client’s output stream PUT – A request for the server to store the data in the request as the new contents of the specified URI DELETE – A request for the server to delete the resource named in the URI OPTIONS – A request for information about what request methods the server supports TRACE – A request for the Web server to echo the HTTP request and its headers CONNECT – Currently unimplemented method reserved for use with a tunneling proxy
8
Part II - Request Headers Second part – one or more request headers Request headers inform the server of client’s identity and capabilities Key/value pairs (key and value separated by colon) E.g: Accept: text/html, image/bmp, text/x-wap.wml one pair per line Typical Request Headers User-Agent ( The vendor and the version of the client) Accept (A list of content types that client recognizes) Content-Length (number of bytes of data appended to the request)
9
Part III – Empty Line This informs the server that no more headers follow Even if no headers exist, this empty line has to be sent so that the server doesn’t look for any more headers
10
HTTP Response from Server Response also has up to four parts: A status line Zero or more response headers An empty line signaling the end of the response headers, and The requested data
11
HTTP Response - Status line The status line consists of three tokens: HTTP version Just as the client indicates the highest version it can understand, the server indicates its capabilities Response code Three digit numeric code that indicates whether the request succeeded or failed, if it failed, the reason why. An optional response description, which is a human readable explanation of the response code Status line example HTTP/1.0 200 OK
12
Client (Browser) Asks… User types the following URL in the browser http://www.lyricnote.com/simple.htm http://www.lyricnote.com/simple.htm Browser opens a socket connection to www.lyricnote.com host on port 80 and then writes the following line and an empty line after that. www.lyricnote.com GET /simple.htm HTTP/1.0
13
Web Server Returns… HTTP/1.1 200 OK Date: Tue, 12 Feb 2002 03:55:43 GMT Server: Apache/1.3.12 (Win32) Content-Length: 241 Content-Type: text/html Welcome to The Lyric Note, the best Internet source for sheet music musical instruments books on musical topics music software, and musical gift items
14
Browser Renders… Browser parses the status line and checks the status code – request was successful The parses response headers Finds out that 241 bytes of html follows Reads html data and renders the document If the html document contains references to other resources, the browser requests the server for those resources E.g: if the document contains an tag, then the browser requests that image. The server doesn’t send the image automatically along with the original request
15
Complex Request http://www.lyricnote.com/compound.htm http://www.lyricnote.com/compound.htm HTTP Request: GET /compound.htm HTTP/1.0 Then the server sends the following….
16
Server Sends… HTTP/1.1 200 OK Date: Tue, 12 Feb 2002 23:55:43 GMT Server: Apache/1.3.12 (Win32) Content-Length: 380 Content-Type: text/html Welcome to The Lyric Note, the best Internet source for sheet music musical instruments books on musical topics music software, and musical gift items
17
Another Request Browser encounters style sheet request Makes a second HTTP request GET /lyricnote.css HTTP/1.0 Web server retrieves the style sheet and sends it to the client HTTP/1.1 200 OK Date: Tue, 12 Feb 2002 23:55:53 GMT Server: Apache/1.3.12 (Win32) Connection: Keep-alive, close Content-Length: 73 Content-Type: text/plain H3 { font-size: 20px; font-weight: bold; color: #005A9C; }
18
Yet Another Request Browser interprets the style sheet and applies it to the document Encounters image tag and makes a request for the logo GET /images/logo.jpg HTTP/1.0 Server responds with image data stream HTTP/1.1 200 OK Date: Tue, 12 Feb 2002 23:55:59 GMT Server: Apache/1.3.12 (Win32) Connection: Keep-alive, close Content-Length: 1280 Content-Type: text/plain (binary image data follows)
19
GET Versus POST GET Form data appended to the URI Simplifies the work the server needs to do Limit to the length of the URI (4KB) Some servers won’t even accept 2KB If you submit form data using GET and book mark the resulting page, then, you don’t have to type the data However, the data is visible – defeats having a password POST Write the data to the client’s output stream Server takes time in processing this data
20
More Info on HTTP W3C – World Wide Web Consortium http://www.w3.org/Protocols/ http://www.w3.org/Protocols/ Freesoft.org http://www.freesoft.org/CIE/RFC/1945/index.htm http://www.freesoft.org/CIE/RFC/1945/index.htm HTTP IETF (Internet Engineering Task Force) http://www-old.ics.uci.edu/pub/ietf/http/ http://www-old.ics.uci.edu/pub/ietf/http/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.