HTTP1 Hypertext Transfer Protocol (HTTP) After this lecture, you should be able to: Know how Web Browsers and Web Servers communicate via HTTP Protocol. HTTP main property: stateless. HTTP Request – HTTP Response.
HTTP2 Client Browser 1 HTTP Request PHP Module 3 4 Apache Web Server HTTP Protocol: Request and Response DB 2 5 MySQL 6 HTTP Response
HTTP3 HTTP Protocol: Request and Response
HTTP4 Hypertext Transfer Protocol (HTTP) HTTP is an application-level protocol for document retrieval used by the World-Wide Web. A client requests a document to be retrieved. A server provides (responds) the requested document. A document is identified by a URL (Uniform Resource Locator). For the latest information, visit
HTTP5 Examples of HTTP URLs The server retrieves file index.html (or index.php) in the root Web directory on host /cs275/ The server retrieves file index.php in directory classes\eecs\summer2010\cs275\public_html on host classes.engr.oregonstate.edu. /cs275/ The client sends a request to a TCP socket connected to port
HTTP6 Hypertext Transfer Protocol (HTTP) HTTP is simple and versatile: generic -- it can be used for various kinds of data. object-oriented -- it supports different kinds of commands (methods). stateless -- the server does not need to remember or worry about the state of the client.
HTTP7 Example of HTTP Request summer2010/cs275/ GET /eecs/summer2010/cs275/ HTTP/1.1 Host: classes.engr.oregonstate.edu User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: ) Gecko/ Firefox/3.6.6 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO ,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive
HTTP8 Server Response HTTP/ OK Date: Mon, 19 Jul :15:08 GMT Server: Apache/2.2.3 (Red Hat) Set-Cookie: SESSbe80a35b84f4d2923d8e921a2f4864ef=pksdju74f0chg9j2 kci37sf457; expires=Wed, 11 Aug :48:29 GMT; path=/; domain=.classes.engr.oregonstate.edu Expires: Sun, 19 Nov :00:00 GMT Last-Modified: Mon, 19 Jul :15:09 GMT Cache-Control: store, no-cache, must-revalidate, post- check=0, pre-check=0 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=utf-8
HTTP9 HTTP Methods GET To retrieve the data identified by the URL. HEAD To retrieve the header information of the entity identified by the URL. POST To request the server to accept the data enclosed in the request. PUT To store the enclosed data under the URL specified. DELETE To delete the entity specified by the URL. OPTIONS To obtain information on available communication options.
HTTP10 Request Syntax Request = Request-Line *( general-header | request-header | entity-header ) CRLF [ message-body ] Request-Line = Method SP Request-URI SP HTTP-Version CRLF Method = "OPTIONS" | "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "TRACE" | extension-method message-body = entity-body |
HTTP11 Request Header request-header = Accept | Accept-Charset | Accept-Encoding | Accept-Language | Authorization | From | Host | If-Modified-Since | If-Match | If-None-Match | If-Range | If-Unmodified-Since | Max-Forwards | Proxy-Authorization | Range | Referer | User-Agent
HTTP12 Response Syntax Response = Status-Line *( general-header | response-header | entity-header ) CRLF [ message-body ] message-body = entity-body |
HTTP13 Status Code Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF Status Code Categories 1xx -- information 2xx -- successful 3xx -- continue 4xx -- client error 5xx -- server error Status-Code = "100" ; Continue | "101" ; Switching Protocols | "200" ; OK | "201" ; Created | "202" ; Accepted | "203" ; Non-Authoritative...
HTTP14 Status Code (cont’d) Status-Code = "100" ; Continue... | "300" ; Multiple Choices | "301" ; Moved Permanently | " 302" ; Moved Temporarily | "400" ; Bad Request | "401" ; Unauthorized | "402" ; Payment Required | "403" ; Forbidden | "404" ; Not Found | "405" ; Method Not Allowed | "406" ; Not Acceptable | "500" ; Internal Server Error | "501" ; Not Implemented | "502" ; Bad Gateway | "503" ; Service Unavailable | "504" ; Gateway Time-out | "505" ; HTTP Version not supported
HTTP15 Example of Status Code summer2010/cs276/ GET /eecs/summer2010/cs276/ HTTP/1.1 Host: classes.engr.oregonstate.edu User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: ) Gecko/ Firefox/3.6.6 … HTTP/ Not Found Date: Mon, 19 Jul :21:46 GMT Server: Apache/2.2.3 (Red Hat) Content-Length: 314 Connection: close Content-Type: text/html; charset=iso
HTTP16 Summary The HTTP protocol is used to retrieve a sequence of bytes, which is often an HTML file. It is a stateless protocol following a simple request/response paradigm. A success or failure of the result is indicated by a status code. It is possible to specify the properties of the document to be retrieved, for example, the encoding method of the image, the language of the text, etc.