HTTP Overview - PowerPoint PPT Presentation

About This Presentation
Title:

HTTP Overview

Description:

Ask for a document by name. Agree on data format. Determine who the user is ... H3 Welcome /H3 to b The Lyric Note /b , the best Internet source for UL LI ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 21
Provided by: sant121
Category:
Tags: http | all | ask | lyrics | of | overview | you

less

Transcript and Presenter's Notes

Title: HTTP Overview


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 servers 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 doesnt
    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.com4311/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 doesnt
    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 clients 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 clients
    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 doesnt 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
  • 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.
  • GET /simple.htm HTTP/1.0

13
Web Server Returns
HTTP/1.1 200 OK Date Tue, 12 Feb 2002 035543
GMT Server Apache/1.3.12 (Win32) Content-Length
241 Content-Type text/html ltHTMLgt ltBODYgt ltH3gtWel
comelt/H3gt to ltbgtThe Lyric Notelt/bgt, the best
Internet source for ltULgt ltLIgtsheet
music ltLIgtmusical instruments ltLIgtbooks on
musical topics ltLIgtmusic software,
and ltLIgtmusical gift items lt/ULgt lt/BODYgt lt/HTMLgt
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 ltimggt tag, then
    the browser requests that image.
  • The server doesnt send the image automatically
    along with the original request

15
Complex Request
  • 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 235543
GMT Server Apache/1.3.12 (Win32) Content-Length
380 Content-Type text/html ltHTMLgt ltHEADgt ltLINK
RELstylesheet HREFlyricnote.cssgt lt/HEADgt ltBO
DYgt ltIMG SRCimages/logo.jpggt ltHR
COLOR005A9C ALIGNLEFT WIDTH500gt ltH3gtWelc
omelt/H3gt to ltbgtThe Lyric Notelt/bgt, the best
Internet source for ltULgt ltLIgtsheet
music ltLIgtmusical instruments ltLIgtbooks on
musical topics ltLIgtmusic software,
and ltLIgtmusical gift items lt/ULgt lt/BODYgt lt/HTMLgt
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 235553
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 235559
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 wont even accept 2KB
  • If you submit form data using GET and book mark
    the resulting page, then, you dont have to type
    the data
  • However, the data is visible defeats having a
    password
  • POST
  • Write the data to the clients output stream
  • Server takes time in processing this data

20
More Info on HTTP
  • W3C World Wide Web Consortium
  • http//www.w3.org/Protocols/
  • Freesoft.org
  • http//www.freesoft.org/CIE/RFC/1945/index.htm
  • HTTP IETF (Internet Engineering Task Force)
  • http//www-old.ics.uci.edu/pub/ietf/http/
Write a Comment
User Comments (0)
About PowerShow.com