Hypertext Transfer Protocol Is Used Between the Browser and a Web Server
Total Page:16
File Type:pdf, Size:1020Kb
HHTTTTPP BByy BBaarrddiiaa ,, PPaattiitt,, aanndd RRoozzhheehh HTTP - Introduction - Hyper Text Transfer Protocol -uses the TCP/IP technology -has had the most impact on the World Wide Web (WWW) - specs in RFC 2616 (RFC2616) HTTP - Importance of The Web • - before HTTP , FTP data transfers accounted for approximately 1/3 of the Internet traffic • - HTTP inception in 1990s and by 2000 Web traffic completely overshadowed other applications HTTP - Importance of The Web (continued) • - companies have web sites, online catalogs • - Internet and Web are indistinguishable for most users • - Uses of the Web include Graphical Design of Information, Dissemination of Research http://info. cern.ch/ (world’s first-ever web server) European organization for Nuclear Research, browsing and ordering of products, client and customer support, display of create arts HTTP - Architectural Components • - Web consists of large set of documents called Web Pages • - web pages considered hypermedia document • - media suffix used to indicate that document contains items other then text , such as graphics • - hyper prefix used to indicate document can contain selectable links • - Hyper Text Markup Language (HTML) used to present mixture of text and images HTTP - Sample HTML Page • <HTML> • <HEAD> • <TITLE>MyPage.html - My Home Page</TITLE> • <SCRIPT></SCRIPT> • </HEAD> • <BODY> • Welcome to My Home Page • </BODY> </HTML> HTTP - Sample HTML Page HTTP - Uniform Resource Locator (URL) • - each page assigned a unique URL name that is used to identify it http://hostname[:port]/path[;parameters][[?query] • - http / ftp = scheme specifies the transfer protocol, • - hostname string specifies the domain name or IP address of the server • - :port is an optional protocol port number needed only in case the server does not use the default port 80 HTTP - simple URL • Example: http://www.csun.edu/ URL - Query • Example: http://www.google.com/search?hl=en&lr=&safe=off& q=the+last+page+on+the+internet&btnG=Search • <html> • <head></head> • <body> • <form> • <input type=text name=“q”> • <input type=submit name="btnG" value="Search"> • </form> • </body> • </html> URL - last comment • Each Web Page is assigned a unique identifier known as a Uniform Resource Locator (URL). The absolute form of a URL contains a full specification; a relative form that omits the address of the server is only useful when the server is implicitly known. Fully validated URL • Good for www.externalsite.com to www.othersite.com • <a accesskey="0" href="http://www.csun.edu/test/accessibility.html">Access key details</a> Internal URL • Good for www.internalsite.com www.internsite.com • Local server validated URL: • <a href="accessibility.html">Accessibility</a> HTTP - Header Definition • HTTP/1.1 header fields. For entity-header fields, both sender and recipient refer to either the client or the server, depending on who sends and who receives the entity. • Example: The most common usage is a clear-text request by the client followed by a server demand to upgrade the connection • Client: • GET /encrypted-area HTTP/1.1 • Host: www.example.com • Server: • HTTP/1.1 426 Upgrade Required • Upgrade: TLS/1.0, HTTP/1.1 • Connection: Upgrade HTTP - Header GET Example • Below is a sample conversation between an HTTP client and an HTTP server running on www.example.com, port 80. • Client request (followed by a blank line, so that request ends with a double newline, each in the form of a carriage return followed by a line feed): • GET /index.html HTTP/1.1 • Host: www.example.com • The "Host" header distinguishes between various DNS names sharing a single IP address, allowing name-based virtual hosting. While optional in HTTP/1.0, it is mandatory in HTTP/1.1. • Server response (followed by a blank line and text of the requested page): • HTTP/1.1 200 OK • Date: Mon, 23 May 2005 22:38:34 GMT • Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) • Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT • Etag: "3f80f-1b6-3e1cb03b" • Accept-Ranges: bytes • Content-Length: 438 • Connection: close • Content-Type: text/html; charset=UTF-8 HTTP Status Codes • * 1 1xx Informational • * 2 2xx Success • * 3 3xx Redirection • * 4 4xx Client Error • * 5 5xx Server Error • * 6 See also • * 7 External links HTTP Status Code - 1xx Informational • Request received, continuing process. • * 100: Continue • * 101: Switching Protocols HTTP Status Code - 2xx Success • The action was successfully received, understood, and accepted. • * 200: OK • * 201: Created • * 202: Accepted • * 203: Non-Authoritative Information • * 204: No Content • * 205: Reset Content • * 206: Partial Content • * 207: Multi-Status • For use with XML-based responses when a number of actions could have been requested – details of the separate statuses are given in the message body. See WebDAV for associated specifications. HTTP Status Code - 3xx Redirection • The client must take additional action to complete the request. * 300: Multiple Choices * 301: Moved Permanently • This and all future requests should be directed to another URI. • * 302: Found • This is the most popular redirect code, but also an example of industrial practice contradicting the standard. HTTP/1.0 specification (RFC 1945) required the client to perform temporary redirect (the original describing phrase was "Moved Temporarily"), but popular browsers implemented it as a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307 to disambiguate between the two behaviors. However, majority of Web applications and frameworks still use the 302 status code as if it were the 303. • See also 302 Google Jacking. • * 303: See Other (since HTTP/1.1) • The response to the request can be found under another URI using a GET method. • * 304: Not Modified • * 305: Use Proxy (since HTTP/1.1) • Many HTTP clients (such as Mozilla and Internet Explorer) don't correctly handle responses with this status code. • * 306 is no longer used, but reserved. Was used for 'Switch Proxy'. • * 307: Temporary Redirect (since HTTP/1.1) In this occasion, the request should be repeated with another URI, but future requests can still be directed to the original URI. In contrast to 303, the original POST request must be repeated with another POST request. HTTP Status Code - 4xx Client Error • The request contains bad syntax or cannot be fulfilled. • * 400: Bad Request • * 401: Unauthorized • Similar to 403/Forbidden, but specifically for use when authentication is possible but has failed or not yet been provided. See basic authentication scheme and digest access authentication. • * 402: Payment Required • The original intention was that this code might be used as part of some form of digital cash/micropayment scheme, but that has never eventuated, and thus this code has never been used. • * 403: Forbidden • * 404: Not Found • * 405: Method Not Allowed • * 406: Not Acceptable • * 407: Proxy Authentication Required • * 408: Request Timeout • * 409: Conflict • * 410: Gone • * 411: Length Required • * 412: Precondition Failed • * 413: Request Entity Too Large • * 414: Request-URI Too Long • * 415: Unsupported Media Type • * 416: Requested Range Not Satisfiable • * 417: Expectation Failed • * 449: Retry With A Microsoft extension: The request should be retried after doing the appropriate action. HTTP Status Code - 5xx Server Error • The server failed to fulfil an apparently valid request. • * 500: Internal Server Error • * 501: Not Implemented • * 502: Bad Gateway • * 503: Service Unavailable • * 504: Gateway Timeout • * 505: HTTP Version Not Supported • * 509: Bandwidth Limit Exceeded • This status code, while used by many servers, is not an official HTTP status code. How a browsers contacts to a web server ? • The browsers begins with a URL, extracts the hostname section, uses DNS to map the name into an equivalent IP Address, and uses the IP address to form a TCP connection to the server. • Once the TCP connection is in place, the browser and web server use HTTP to communicate; the browser sends a request to retrieve a specific page and the server responds by sending a copy of the page HTTP GET REQUEST A browser sends an HTTP GET command to request a web page from a server. The request consist of a single line of text that begins with key word “GET” followed by a URL and an HTTP version number Example: If we want to retrieve the web page for comp429 from server wwwwww..ccssuunn..eedduu a browser can send the following request: • GEThttp://www.csun.edu/comp429/officehour/http/1.1 • Once a TCP connection is in place, there no need to send an absolute URL --- the following relative URL will retrieve the same page GET /comp429/officehour/http/1.1 TO SUMMARIZE: • The HTTP or Hypertext transfer Protocol is used between the browser and a web server. The browser send a GET request to which a server responds by sending the requested item. What should a web server respond when it receives an illegal request? The answer is simple the sever send the error message to the browsers via HTML. Why? - because since the request has been sent by a browser, so the browser will attempt to display whatever the server returns. Example of an Error Messages: <html> <head><title>400 bad request</title> </head> <body> <h1>bad request</h1>your browser sent a request that this server could not understand </body> </html> it will appear on the user’s screen like bad request your browser sent a request that this server could not understand. Persistent Connections • The first version of HTTP used TCP connection per data transfer. • As a result it was increasing the load on HTTP server causing congestion on the internet. • So later the new version of HTTP was implemented. (HTTP version 1.1) What new in HTTP version1.1? • Using persistent connection approach as the default. That is once a client opens a TCP connection to server, the client leaves the connection in place during multiple requests and responses. When either a client or server is ready to close the connection, it informs the other side ,and the connection is closed.