HTTP request message two types of HTTP messages:request,response HTTP request message: ASCll (human-readable format) carriage return character line-feed character request line(GET,POST, GET /index.html ETTP/1.1\r\n HEAD commands) Host:www-net.cs.umass.edu\r\n User-Agent:Firefox/3.6.10\r\n header Accept:text/html,application/xhtml+xml\r\n Accept-Language:en-us,en;q=0.5\r\n lines Accept-Encoding:gzip,deflate\r\n Accept-Charset:ISO-8859-1,utf-8;q=0.7\r\n Keep-Alive:115\r\n Connection:keep-alive\r\n carriage return,line feed IrIn at start of line indicates end of header lines Check out the online interactive exercises for more examples:http://gaia.cs.umass.edu/kurose_ross/interactive/ Application Layer:2-26
HTTP request message Application Layer: 2-26 ▪ two types of HTTP messages: request, response ▪ HTTP request message: • ASCII (human-readable format) request line (GET, POST, HEAD commands) header lines carriage return, line feed at start of line indicates end of header lines GET /index.html HTTP/1.1\r\n Host: www-net.cs.umass.edu\r\n User-Agent: Firefox/3.6.10\r\n Accept: text/html,application/xhtml+xml\r\n Accept-Language: en-us,en;q=0.5\r\n Accept-Encoding: gzip,deflate\r\n Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n Keep-Alive: 115\r\n Connection: keep-alive\r\n \r\n carriage return character line-feed character * Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
HTTP request message:general format method sp URL sp version request line header field name value cr header lines header field name value cr f cr f entity body body Application Layer:2-27
HTTP request message: general format Application Layer: 2-27 request line header lines body method sp URL sp version cr lf header field name value cr lf header field name value cr lf ~~ ~~ cr lf ~ entity body ~ ~~
Other HTTP request messages POST method: HEAD method: web page often includes form requests headers (only)that input would be returned if specified user input sent from client to URL were requested with an server in entity body of HTTP HTTP GET method. POST request message PUT method: uploads new file (object)to server GET method (for sending data to server): completely replaces file that exists include user data in URL field of HTTP at specified URL with content in GET request message(following a?'): entity body of POST HTTP request www.somesite.com/animalsearch?monkeyssbanana message Application Layer:2-28
Other HTTP request messages Application Layer: 2-28 POST method: ▪ web page often includes form input ▪ user input sent from client to server in entity body of HTTP POST request message GET method (for sending data to server): ▪ include user data in URL field of HTTP GET request message (following a ‘?’): www.somesite.com/animalsearch?monkeys&banana HEAD method: ▪ requests headers (only) that would be returned if specified URL were requested with an HTTP GET method. PUT method: ▪ uploads new file (object) to server ▪ completely replaces file that exists at specified URL with content in entity body of POST HTTP request message
HTTP response message status line(protocol HTTP/1.1 200 OK\r\n status code status phrase) Date:Sun,26 Sep 2010 20:09:20 GMT\r\n Server:Apache/2.0.52 (Centos)\r\n Last-Modified:Tue,30 Oct 2007 17:00:02 GMT\r\n header ETag:"17dc6-a5c-bf716880"\r\n Accept-Ranges:bytes\r\n lines Content-Length:2652\r\n Keep-Alive:timeout=10,max=100\r\n Connection:Keep-Alive\r\n Content-Type:text/html;charset=ISO-8859- 1\r\n Ir\n data,e.g.,requested data data data data data .. HTML file Check out the online interactive exercises for more examples:http://gaia.cs.umass.edu/kurose_ross/interactive/ Application Layer:2-29
HTTP response message Application Layer: 2-29 status line (protocol status code status phrase) header lines data, e.g., requested HTML file HTTP/1.1 200 OK\r\n Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n Server: Apache/2.0.52 (CentOS)\r\n Last-Modified: Tue, 30 Oct 2007 17:00:02 GMT\r\n ETag: "17dc6-a5c-bf716880"\r\n Accept-Ranges: bytes\r\n Content-Length: 2652\r\n Keep-Alive: timeout=10, max=100\r\n Connection: Keep-Alive\r\n Content-Type: text/html; charset=ISO-8859- 1\r\n \r\n data data data data data ... * Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
HTTP response status codes status code appears in 1st line in server-to-client response message. some sample codes: 2000K request succeeded,requested object later in this message 301 Moved Permanently requested object moved,new location specified later in this message(in Location:field) 400 Bad Request request msg not understood by server 404 Not Found requested document not found on this server 505 HTTP Version Not Supported Application Layer:2-30
HTTP response status codes Application Layer: 2-30 200 OK • request succeeded, requested object later in this message 301 Moved Permanently • requested object moved, new location specified later in this message (in Location: field) 400 Bad Request • request msg not understood by server 404 Not Found • requested document not found on this server 505 HTTP Version Not Supported ▪ status code appears in 1st line in server-to-client response message. ▪ some sample codes: