160 likes | 236 Views
HTTP Fundamentals Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL. HTTP:Overview. A protocol which defines how communication should occur between browsers and web servers. Must specify: How a request for a page is packaged.
E N D
HTTP Fundamentals Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL
HTTP:Overview • A protocol which defines how communication should occur between browsers and web servers. • Must specify: • How a request for a page is packaged. • How the response to a request for a page is packaged. • Which types of errors associated with request processing the servers should detect and report.
HTTP Overview • HTTP is basically stateless. This means servers are not required to retain information about a request after the request has been serviced even if the user continues accessing the same server for minutes or hours. • Enhances scalability. Not being required to retain information about a client means that successive requests can be serviced by different machines. • Generally less efficient. • HTTP 1.1 improves efficiency by allowing connections to clients to be kept-alive between requests.
HTTP Request Handling : Static Pages Server Browser Request Lookup Page [Page Found] Packaged Web Page [Page not Found] Packaged Error Mess Render Page
HTTP Request Handling :Servlets Server Browser Request Parse Form Data [Servlet Not Loaded] Load Servlet [Servlet Loaded] Launch Thread to Service Request Produce Web Page Packaged Web Page Render Page
URLs – Uniform Resource Locator • Example: http://www.sheridanc.on.ca/~joe/index.html • Three components PROTOCOL + HOST + FILENAME • Protocol examples: http, ftp, telnet • Name or ip address of host machine. • www.sheridanc.on.ca • 142.76.45.112 • Sometimes host names also include the port number e.g. www.sheridanc.on.ca:8805 • File name: directory and file name of resource
What are Hosts? • A host is a machine or entity on the web that listens for HTTP requests. • Hosts may be able to listen on more than one port for incoming requests. The port acts as a receiving channel. • Ports are identified by numbers e.g. 5705. • Example of URL with a port number. • http://www.myhostingsite.com:6706/a.html
HTTP Request Structure • Request = Request-Line • *(( general-header • request-header • entity-header ) CRLF) • CRLF • [ message-body ] • Request-Line = Method SP Request-URI SP HTTP-Version CRLF • Method = OPTIONS • GET • HEAD • POST • PUT • DELETE • TRACE • CONNECT • extension-method • extension-method = token • Request-URI = * absoluteURI abs_path authority • HTTP-Version = HTTP/1.0 HTTP/1.1
Types of HTTP Status Codes • 1xx Informational Inform browser client of server operation. • 2xx Success • 3xx Redirection • 4xx Client Error Problems with request formatting or invalid URI address coming from browser. • 5xx Server Error. Client Request assumed valid but could not be serviced.
Specific HTTP Status Codes • 201 ; Created • 202 ; Accepted • 203 ; Non-Authoritative Information • 204 ; No Content • 301 ; Moved Permanently • 307 ; Temporary Redirect • 400 ; Bad Request • 401 ; Unauthorized • 402 ; Payment Required • 403 ; Forbidden • 404 ; Not Found • 500 ; Internal Server Error • 501 ; Not Implemented • 502 ; Bad Gateway
HTTP Protocol - Commands • OPTIONS • GET • HEAD • POST • PUT • DELETE • TRACE • CONNECT
HTTP:GET • Get the document specified by the URI • Modifiable with conditions: • If-Match • If-Modified-Since • If-None-Match • If-Unmodified-Since
HTTP:Other Commands • POST • Is sometimes used in place of GET but usually associated with active content or when form data must be transferred. • PUT • Used when a server is requested to store the sent data under the URI name. • DELETE • Used when the server is requested to delete the resource associated with the URI name.