Presentation is loading. Please wait.

Presentation is loading. Please wait.

IS333D: MULTI-TIER APPLICATION DEVELOPMENT

Similar presentations


Presentation on theme: "IS333D: MULTI-TIER APPLICATION DEVELOPMENT"— Presentation transcript:

1 IS333D: MULTI-TIER APPLICATION DEVELOPMENT
Lecture 5: HTTP

2 Information Systems Department
Objectives To provide an overview of how the HTTP works in the context of a simple page request. To learn about client-side caching. To know how to access to a web server. 21-Sep-18 Information Systems Department

3 Information Systems Department
HTTP The hypertext transport protocol (HTTP) defines a simple series of procedures by which a client computer may make a request of a server computer, and the server computer may reply. The protocol is central to the everyday operation of the World Wide Web, in which it is used to request and provide files to browsers in response to URL entries and clicks on hyperlinks. 21-Sep-18 Information Systems Department

4 Information Systems Department
HTTP: Part of a URL A URL contains information that directs a browser to the resource that the user wishes to access. Web servers make such resources available to web clients. Let’s examine the component of the URL: 21-Sep-18 Information Systems Department

5 Information Systems Department
HTTP: Part of a URL Indicates that the HyperText Transfer Protocol (HTTP) should be used to obtain the resource. Hostname – the name of the web server computer on which the resource resides. This computer is referred to as the host, because it houses and maintain resources. 21-Sep-18 Information Systems Department

6 Information Systems Department
HTTP: Part of a URL books/downloads.htm Specifies the resource’s location (/book) and name (downloads.html) on the web server 21-Sep-18 Information Systems Department

7 Making a Request and Receiving a Response
The one making a request is the HTTP client and the one responding to that request is the HTTP server. When given a web page URL, a web browser uses HTTP to request the web page found at that address. 21-Sep-18 Information Systems Department

8 Making a Request and Receiving a Response
a) The request is sent from the web client to the web server Internet Web Client Web Server b) After it receives the request, the web server searches its system for the resource Fig 1. A web browser sending a GET request to a web server 21-Sep-18 Information Systems Department

9 Making a Request and Receiving a Response
Fig. 1 shows the GET request. The web browser sends an HTTP request to the server. The request (in its simplest form) is: GET /books/downloads.html HTTP/1.1 21-Sep-18 Information Systems Department

10 Making a Request and Receiving a Response
GET is an HTTP method indicating that the client wishes to obtain a resource from the server. The remainder of the request provides the path name of the resource (e.g., an HTML5 document) and the protocol’s name and version number (HTTP/1.1). The client’s request also contains some required and optional headers. There is a blank line at the end of an HTTP GET request to terminate the header. 21-Sep-18 Information Systems Department

11 Making a Request and Receiving a Response
Internet Web Client Web Server The server responds to the request with the resource’s contents Fig 2. A web server replying the HTTP respond to a web client 21-Sep-18 Information Systems Department

12 Making a Request and Receiving a Response
Any server that understands HTTP (version 1.1) can translate the request and respond appropriately. Fig. 2 shows the web server responding to a request. The server first sends a line of text that indicates the HTTP version, followed by a numeric code and a phrase describing the status of the transaction. Eg.: HTTP/ OK, which indicates success 21-Sep-18 Information Systems Department

13 Making a Request and Receiving a Response
E.g.: HTTP/ Not found, which informs the client that the web server could not locate the requested resource. A complete list of numeric codes can be found at Each series of response codes corresponds to a particular class of conditions: 200-series codes indicate success. 300-series codes indicate a redirection to a new URL. 400-series codes indicate a client-side error (like a request for a nonexistent document—the famous “404 Not Found” error). 500-series codes indicate a server-side error. 21-Sep-18 Information Systems Department

14 Making a Request and Receiving a Response
Next, the server sends one or more HTTP headers, which provide additional information about the data that will be sent. In this case, the server is sending an HTML5 text document, so one HTTP header for this example would read: Content-type: text/html 21-Sep-18 Information Systems Department

15 Making a Request and Receiving a Response
The information provided in the header specifies the Multipurpose Internet Mail Extension (MIME) type of the content that the server is transmitting to the browser. The MIME standard specifies data formats, which programs can use to interpret data correctly. Other MIME example: text/plain – text content that can be displayed directly image/jpeg – JPEG image content 21-Sep-18 Information Systems Department

16 Making a Request and Receiving a Response
The header or set of headers is followed by a blank line, which indicates to the client browser that the server is finished sending HTTP headers. Finally, the server sends the contents of the requested document (downloads.html). 21-Sep-18 Information Systems Department

17 Anatomy of an HTTP Transaction
When a user of a browser enters a URL or clicks a link: 21-Sep-18 Information Systems Department

18 Anatomy of an HTTP Transaction
GET / HTTP/ Client: request line host: Client: required HTTP/1.1 HOST header Client: blank line terminates headers. HTTP/ OK Server: response line MIME-Version: Server: followed by five response headers Date: Mon, 08 Jan :59:42 GMT Server: NaviServer/2.0 AOLserver/2.3.3 Content-Type: text/html Server: expect HTML in the response body Content-Length: Server: expect 42,092 bytes in the resp. body Server: blank line terminates headers <html> Server: first HTML line in response body Server: 766 lines of HTML not shown. </html> Server: last HTML line in response body Connection closed by foreign host Server: closes connection 21-Sep-18 Information Systems Department

19 Information Systems Department
Request Method Two most common HTTP request types: GET POST A GET request typically gets (or retrieves) information from a server, such as an HTML document, an image or search results based on a user-submitted search term. A POST request typically posts (or sends) data to a server. Common use of post requests are to send form data or documents to a server. 21-Sep-18 Information Systems Department

20 Information Systems Department
Request Method (Cont.) An HTTP request often posts data to a server-side form handler that processes the data. For example, when a user performs a search or participates in a web-based survey, the web server receives the information specified in the HTML form as part of the request. Get and post requests can both be used to send data to a web server, but each request type sends the information differently. 21-Sep-18 Information Systems Department

21 Information Systems Department
Using GET Request A GET request appends data to the URL, e.g., In this case, search is the name of Google’s server-side form handler, q is the name of a variable in Google’s search form and deitel is the search term. The ? in the preceding URL separates the query string from the rest of the URL in a request. A name/value pair is passed to the server with the name and the value separated by an equals sign (=). 21-Sep-18 Information Systems Department

22 Using GET Request (Cont.)
If more than one name/value pair is submitted, each pair is separated by an ampersand (&). The server uses data passed in a query string to retrieve an appropriate resource from the server. The server then sends a response to the client. A GET request may be initiated by submitting an HTML form whose method attribute is set to “get”, or by typing the URL (containing a query string) directly into the browser’s address bar. 21-Sep-18 Information Systems Department

23 Information Systems Department
Using POST Request A POST request sends form data as part of the HTTP message, not as part of the URL. The POST method can send large amount of information. The POST method is sometimes preferred because it hides the submitted data from the user by embedding it in an HTTP message. URL generated by the POST method: 21-Sep-18 Information Systems Department

24 Information Systems Department
Client-Side Caching Browsers often cache (save on disk) recently viewed web pages for quick reloading. If there are no changes between the version stored in the cache and the current version on the web, this speeds up your browsing experience. An HTTP response can indicate the length of time for which the content remains “fresh”. If this amount of time has not been reached, the browser can avoid another request to the server. 21-Sep-18 Information Systems Department

25 Client-Side Caching (Cont.)
If not, the browser loads the document from the cache. Similarly, there’s also the “not modified” HTTP response, indicating that the file content has not changed since it was last requested. Browsers typically do not cache the server’s response to a POST request, because the next POST might not return the same result. 21-Sep-18 Information Systems Department

26 Information Systems Department
Accessing Web Server To request documents from web servers, users must know the hostnames on which the web server software resides. Users can request documents from local web servers (i.e., ones residing on users’ machines) or remote web servers (i.e., ones residing on different machines). 21-Sep-18 Information Systems Department

27 Accessing Web Server (Cont.)
Local web servers can be accessed through your computer’s name or through the name localhost – a hostname that references the local machine and normally translate to the IP address A remote web server referenced by a fully qualified hostname or an IP address can also serve documents. E.g.: the is the server’s fully qualified hostname. 21-Sep-18 Information Systems Department

28 Accessing Web Server (Cont.)
Example of web server software: Apache IIS (Microsoft Internet Information Services) Orion 21-Sep-18 Information Systems Department

29 Information Systems Department
References Multi-tier Application Programming with PHP, Practical Guide for Architect and Programmer, David Wall, 1st Edition Internet and World Wide Web How To Program, Deitel, Deitel & Deitel, 5th Edition (Chapter 17) 21-Sep-18 Information Systems Department


Download ppt "IS333D: MULTI-TIER APPLICATION DEVELOPMENT"

Similar presentations


Ads by Google