Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tutorial (4): HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Similar presentations


Presentation on theme: "Tutorial (4): HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display."— Presentation transcript:

1 Tutorial (4): HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

2 Topics discussed in this section:
HTTP The Hypertext Transfer Protocol (HTTP) is a protocol used mainly to access data on the World Wide Web. HTTP functions as a combination of FTP and SMTP. Topics discussed in this section: HTTP Transaction Persistent Versus Non persistent Connection

3 HTTP uses the services of TCP on well-known port 80.
Note HTTP uses the services of TCP on well-known port 80.

4 Figure 27.12 HTTP transaction

5 Figure 27.13 Request and response messages

6 Figure 27.14 Request and status lines

7 Table Methods A head does not require the server to send us the content of the requested file, but simply an acknowledgement that the file is available. The GET will request the complete file from the server

8 Table Status codes

9 Table 27.2 Status codes (continued)

10 Figure Header format

11 Table 27.3 General headers

12 Table Request headers

13 Table 27.5 Response headers

14 Table Entity headers

15 Example 27.1 This example retrieves a document. We use the GET method to retrieve an image with the path /usr/bin/image1. The request line shows the method (GET), the URL, and the HTTP version (1.1). The header has two lines that show that the client can accept images in the GIF or JPEG format. The request does not have a body. The response message contains the status line and four lines of header. The header lines define the date, server, MIME version, and length of the document. The body of the document follows the header (see Figure 27.16).

16 Figure Example 27.1

17 MIME (Multi-Purpose Internet Mail Extensions) *
MIME (Multi-Purpose Internet Mail Extensions) is an extension of the original Internet   protocol that lets people use the protocol to exchange different kinds of data files on the Internet: audio, video, images, application programs, and other kinds, as well as the ASCII text Servers insert the MIME header at the beginning of any Web transmission. Clients use this content type or media type header to select an appropriate "player" application for the type of data the header indicates.

18 MIME * اختصار لمصطلح multipurpose internet mail extensions "
حيث من المعروف أن اى رسالة إلكترونية تتكون من ثلاث اجزاء العنوان المرسل إليه وبشكل تلقائى البريد الإلكترونى للراسل ثم موضوع الرسالة التى سوف يتم إرسالها هذا بالإضافة إلى الجزء الخاص بالنص او محتوى الرسالة وهذا هو الشكل المعتاد فى خدمات البريد الإلكترونى المختلفة على الأنترنت . بالإضافة إلى ما سبق يمكنك أيضاً ارفاق ملفات مثل الصور , الفيديوهات , ملفات العمل الى غير ذالك من انواع الملفات التى يمكن أن نرفقها فى الرسالة من هنا يظهر معنى MIME وهو شكل او امتداد للملفات المرفقة مع الرسالة وبالتالى أسهل وسيلة لفتح هذه الملفات مجرد الضغط عليها بحيث تترك المجال لنظام التشغيل يقوم بتشغيلها طبقاً للتطبيق الداعم لنوعية الملف .

19 Example 27.2 In this example, the client wants to send data to the server. We use the POST method. The request line shows the method (POST), URL, and HTTP version (1.1). There are four lines of headers. The request body contains the input information. The response message contains the status line and four lines of headers. The created document, which is a CGI document, is included as the body (see Figure 27.17).

20 Figure Example 27.2

21 Common Gateway Interface *
The common gateway interface (CGI) is a standard way for a Web server to pass a Web user's request to an application program and to receive data back to forward to the user. When the user requests a Web page (for example, by clicking on a highlighted word or entering a Web site address), the server sends back the requested page.

22 Common Gateway Interface *
However, when a user fills out a form on a Web page and sends it in, it usually needs to be processed by an application program. The Web server typically passes the form information to a small application program that processes the data and may send back a confirmation message. This method or convention for passing data back and forth between the server and the application is called the common gateway interface (CGI). It is part of the Web's Hypertext Transfer Protocol (HTTP).

23 Common Gateway Interface *

24 HTTP version 1.1 specifies a persistent connection by default.
Note HTTP version 1.1 specifies a persistent connection by default.

25 Persistent vs non-persistent HTTP connections
default for HTTP/1.1 on same TCP connection: server, parses request, responds, parses new request,.. less slow start. HTTP/1.0 server parses request, responds, and closes TCP connection Each object transfer suffers from slow start

26 Example 1 Where will each figure be shown on the screen?
Look at the following picture: then tell me what you feel: <IMG SRC="PictureslFunnyl.gif" ALIGN=middle> <lMG SRC="Pictures/Funny2.gif" ALIGN=bottom> <B>What is your feeling? <IE>

27 Example #1 ,Ans The first picture will be centered and the second will be at the bottom.

28 Script* In the dawn of the Internet revolution, web pages were HTML based – they looked good, but could not provide the rich functionality that we are used to today. This is the time when scripting languages  Scripts are invisible to the visitor's eye but their availability within the code of a website defines how the website behaves in response to certain click requests sent by the user

29 Script * In computer programming, a script is a program or sequence of instructions that is interpreted or carried out by another program rather than by the computer processor(as a compiled program is). Some languages have been conceived expressly as script languages. Among the most popular are Perl, PHP   JavaScript. A script is sometimes used to mean a list of operating system commands that are prestored in a file and performed sequentially by the operating system's command interpreter

30 What are JavaScript, PHP and Perl? *
Since the HTML/CSS combination is analogous to the data found in a Word document, it is good only for displaying information. If you want your web pages to do different things depending on the situation, you will need a programming language. For example, some websites want to provide a membership facility where people can log into the site, and access certain information. Other sites provide a feedback form so that visitors can contact them. All these things require facilities that a simple document format cannot do. JavaScript, PHP and Perl are three of the most commonly-used programming languages on the Internet. They are used by websites to carry out more complicated operations.

31 Client site script * Programs written in JavaScript run in the web browser itself, so if your website has a JavaScript program, the program will be automatically fetched by your visitor's browser and executed on his/her computer.

32 Example of java script *
For more info visit :

33 Server site script * PHP and Perl programs, on the other hand, run on the computer where your website is located, that is, on your web host's computer. After the PHP or Perl program does what it needs to do, it sends the result to the visitor's web browser, which displays the results. For more info visit :

34 Example 2 2. Show a request that retrieves the document /usr/users/doc/doc1. Use : at least two general headers, two request headers, and one entity header.

35 Example #2 ,Ans GET /usr/users/doc/doc.1 HTTP /1.1
Date: Fri, 13-Jan-06 08:45:20 GMT MIME-version: 1.0 Accept: image/gif Accept: image/jpeg Last modified: Mon, 09-Jan-06

36 Example 3 3. Show the response to Exercise 2 for a successful request

37 Example #3 ,Ans HTTP/1.1 200 OK Date: Fri, 13-Jan-06 08:45:25 GMT
Server: Challenger MIME-version: 1.0 Content-length: 4623 (Body of document)

38 Example 4 4. Show the response to Exercise 2 for a document that has permanently moved to /usr/deads/doc1.

39 Example #4 ,Ans HTTP/ Moved permanently Date: Fri, 13-Jan-06 08:45:25 GMT Server: Challenger Location: /usr/deads/doc.1

40 Example 5 5. Show the response to Exercise 2 if there is a syntax error in the request.

41 Example #5 ,Ans HTTP/1.1 400 Bad Request
Date: Fri, 13-Jan-06 08:45:25 GMT Server: Challenger

42 Example 6 6. Show the response to Exercise 2 if the client is unauthorized to access the document

43 Example #6 ,Ans HTTP/ Unauthorized Date: Fri, 13-Jan-06 08:45:25 GMT Server: Challenger

44 Example 7 7. Show a request that asks for information about a document at /bin/users/file. Use at least: two general headers and one request header.

45 Example #7 ,Ans HEAD /bin/users/file HTTP /1.1 Date: Fri, 13-Jan-06 10:40:22 GMT MIME-version: 1.0 From:

46 Example 8 8. Show the request to copy the file at location /bin/usr/bin/file1 to /bin/file1. Use at least: two general headers and one entity header.

47 9. Show the response to Exercise 8, for a successful request.
Example 9 9. Show the response to Exercise 8, for a successful request.


Download ppt "Tutorial (4): HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display."

Similar presentations


Ads by Google