100 likes | 119 Views
CITA 310 Section 2. HTTP. How a Web Server Works. HTTP (Hypertext Transfer Protocol) defines how information is passed between a browser and a Web server. The two most popular Web servers are Apache from Apache Software Foundation Internet Information Services (IIS) from Microsoft
E N D
CITA 310 Section 2 HTTP
How a Web Server Works • HTTP (Hypertext Transfer Protocol) defines how information is passed between a browser and a Web server. • The two most popular Web servers are • Apache from Apache Software Foundation • Internet Information Services (IIS) from Microsoft • The original Web server from Microsoft available on Windows NT was Internet Information Server
How a Web Server Works • As is true with other servers such as DNS, Web servers listen for communication at a port. • The default port is 80. • You can also create Web servers at port numbers greater than 1023. • Each Web server has a document root, which is where you store the HTML documents.
Understanding HTTP • The current version of HTTP is 1.1. • Virtually no browsers are so old that they do not support 1.1. • HTTP is a stateless protocol, meaning that each Web page sent is independent of every other Web page sent. • This makes it more challenging to create a shopping cart application.
Understanding HTTP • HTTP 1.1 supports persistent connections. • This allows the browser to receive multiple files in one TCP connection. • This can speed up communication. • Although you see a single page in your browser, it can be composed of many text and image files.
URL Generalized Syntax • [scheme://] [username[:password]@] host[:port][/path] [?query][#fragment]
HTTP Request Example • When the browser sends a request to a Web server, it looks like: GET /hello.htm HTTP/1.1 Host: www.technowidgets.com • The above requests the hello.htm file from the document root of the Web server. • It specifies the host of www.technowidgets.com. • There could be multiple hosts at the IP address.
HTTP Methods • GET • HEAD • POST • PUT • OPTIONS • DELETE • TRACE • CONNECT
HTTP Response Example • The following shows some of the headers along with the HTML that the Web server would send: HTTP/1.1 200 OK Server: Microsoft-IIS/6.0 Content-Type: text/html Last-Modified: Fri, 17 May 2008 18:21:25 GMT Content-Length: 43 <html><body> Hello World! </body></html> • The headers contain information about the page
Sample HTTP Response Status Codes 200 OK • request succeeded, requested object later in this message 301 Moved Permanently • requested object moved, new location specified later in this message 400 Bad Request • request message not understood by server 404 Not Found • requested document not found on this server 505 HTTP Version Not Supported