httprequestmessagegeneralformat method sp URL sp version cr If request line header field name value crIf header lines header field name alue crIf crIf Entity Body 2: Application Layer 16
2: Application Layer 16 http request message: general format
httpmessageformatresponse status line (proToco status code Http/1.0200 ok status phrase) Date: Thu, 06 Aug 1998 12: 00: 15 GMT Server: Apache/1.3.0(Unix) header Last-Modified: Mon, 22 Jun 1998 lines Content-Length: 6821 Content-Type: text/html data datadata data data data, e.g requested html file 2: Application Layer 17
2: Application Layer 17 http message format: response HTTP/1.0 200 OK Date: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ... status line (protocol status code status phrase) header lines data, e.g., requested html file
httpresponsestatuscodes In first line in server->client response message a few sample codes: 200oK m request succeeded, requested object later in this message 301 Moved Permanently m requested ob ject moved new location specified later in this message location 400 Bad Request n request message not understood by server 404 Not Found n requested document not found on this server 505 Http Version Not suPported 2: Application Layer 18
2: Application Layer 18 http response status codes 200 OK m request succeeded, requested object later in this message 301 Moved Permanently m requested object moved, new location specified later in this message (Location:) 400 Bad Request m request message not understood by server 404 Not Found m requested document not found on this server 505 HTTP Version Not Supported In first line in server->client response message. A few sample codes:
Tryingouthttp(clientsideforyourself 1. Telnet to your favorite web server telnetwww.eurecom.fr80opensTcpconnectiontoport80 defaulthttpserverport)atwww.eurecom.fr. Anything typed in sent toport80atwww.eurecom.fr 2.TypeinaGethttprequest Get /-Ross/index. html HttP/1.0 By typing this in(hit carriage return twice), you send this minimal (but complete) Getrequesttohttpserver 3.lOokatresponsemessagesentbyhttpserver 2: Application Layer 19
2: Application Layer 19 Trying out http (client side) for yourself 1. Telnet to your favorite Web server: Opens TCP connection to port 80 (default http server port) at www.eurecom.fr. Anything typed in sent to port 80 at www.eurecom.fr telnet www.eurecom.fr 80 2. Type in a GET http request: GET /~ross/index.html HTTP/1.0 By typing this in (hit carriage return twice), you send this minimal (but complete) GET request to http server 3. Look at response message sent by http server!
User-server interaction; authentication Authentication: control access client server to server content r authorization credentials usualhttprequestmsg typically name, password 401: authorization req r stateless: client must present ww authen七 icate authorization in each request m authorization: header line in usualhttprequestmsg each request Authorization <cred> if no authorization header usualhttpresponsemsg server refuses access sends www authenticate usualhttprequestmsg Authorization <cred> header line in response usualhttpresponsemsg time 2: Application Layer 20
2: Application Layer 20 User-server interaction: authentication Authentication : control access to server content r authorization credentials: typically name, password r stateless: client must present authorization in each request m authorization: header line in each request m if no authorization: header, server refuses access, sends WWW authenticate: header line in response client server usual http request msg 401: authorization req. WWW authenticate: usual http request msg + Authorization: <cred> usual http response msg usual http request msg + Authorization: <cred> usual http response msg time