Download presentation
Presentation is loading. Please wait.
Published byTamsyn Short Modified over 9 years ago
1
Appendix E: Overview of HTTP ©SoftMoore ConsultingSlide 1
2
HTTP Hypertext Transfer Protocol Specification: http://www.w3.org/Protocols/rfc2616/rfc2616.html Set of rules for transferring resources (files, images, etc.) over the web A resource on the web is usually identified by a URL (Uniform Resource Locator) Characteristics –simple –stateless –text-based –request/response protocol Slide 2©SoftMoore Consulting
3
Structure of an HTTP Transaction HTTP client (e.g., a browser) opens a connection and sends a request message to an HTTP server. Server formulates and returns a response message, usually containing the resource that was requested. After delivering the response, the server closes the connection. Connection information is not maintained between transactions. Slide 3©SoftMoore Consulting
4
HTTP Example From the command prompt, enter the following commands: –telnet –set localecho –open www.mathcs.citadel.edu 80 –GET /index.html HTTP/1.1 – Slide 4©SoftMoore Consulting
5
HTTP Message Format Both request and response messages have a similar format: an initial line zero or more lines known as headers a blank line an optional message body (e.g. a file, query data, binary data, etc.) Slide 5©SoftMoore Consulting
6
Initial Request Line The initial line of a request has three parts, separated by spaces: Method name –GET is the most common HTTP method –Other methods include POST and HEAD –Method names are always uppercase Local path of the requested resource –the request URI (a URI is like a URL, but more general) Version of HTTP being used –Always takes the form “HTTP/x.x” Slide 6©SoftMoore Consulting
7
Initial Response Line (a.k.a. the Status Line) The initial line of a response also has three parts, separated by spaces: The HTTP version –same format as the initial request line, “HTTP/x.x” A response status code that gives the result of the request –Examples: 200 or 404 An English phrase describing the status code. –Examples: “OK” or “Not Found” Slide 7©SoftMoore Consulting Example: HTTP/1.0 200 OK
8
Common Status Codes 200 OK –request succeeded; resource is returned in the message body 404 Not Found –requested resource doesn’t exist 301 Moved Permanently 302 Moved Temporarily 303 See Other (HTTP 1.1 only) –resource has moved to the URL given in the “Location” response header; should be automatically retrieved by the client 500 Server Error –unexpected server error Slide 8©SoftMoore Consulting
9
HTTP Methods HTTP defines a set of text-based request messages called methods (not to be confused with Java methods) GET POST HEAD Others –PUT –DELETE –CONNECT –etc. Slide 9©SoftMoore
10
Using HTTP GET Requests The HTTP GET method requests information from a web server The handling of a GET method is expected to be –safe: it does not have any side effects for which users are held responsible –idempotent: it can safely be repeated. This allows a client to repeat a GET request without penalty. Intuitively, GET should be “looking without touching.” If processing has side effects, use another HTTP method, such as POST. Slide 10©SoftMoore
11
Important Limitation on HTTP GET Requests Most web servers limit how much data can be passed as part of the URL name (usually a few hundred bytes). If more data must be passed between the client and the server, the HTTP POST method should be used instead. Slide 11©SoftMoore data as part of the URL
12
Example: HTTP Response to a GET Method HTTP/1.1 200 Document follows Date: Tue, 14 Apr 2007 09:25:19 PST Server: JWS/1.1 Last-modified: Mon, 17 Jun 2005 21:53:08 GMT Content-type: text/html Content-length: 4435 Slide 12©SoftMoore
13
The HEAD Method Similar to the HTTP GET method Server returns only the header information. HEAD is often used to check the following: –last-modified date of a document on the server for caching purposes –size of a document before downloading –server type –type of the requested document Slide 13©SoftMoore
14
The POST Method Allows a client to send data to the server Passes all of its parameter data in an input stream Unlike the GET method, POST –may cause side effects –is not required to be repeatable Several purposes –posting information to a newsgroup –adding entries to a web site's guest book –passing more information than a GET request allows Slide 14©SoftMoore
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.