WWW & HTTP د. عـــادل يوسف أبو القاسم. W ORLD W IDE W EB ( WWW ) W 3 The World...

Post on 27-Dec-2015

218 views 4 download

transcript

WWW & HTTPالقاسم. د أبو يوسف عـــادل

WORLD WIDE WEB (WWW) W3

The World Wide Web (abbreviated as WWW or W3,  commonly known as the web) is a system of interlinked hypertext documents accessed via the Internet.

 With a web browser, one can view web pages that may contain text, images, videos, and other multimedia and navigate between them via hyperlinks.

ARCHITECTURE OF WWW

URL

WEB DOCUMENTS ال الويب documentsتصنف في

هي اصناف ثالثة و staticالىdynamic وactive.

الزمن على يعتمد التصنيف هذاال محتوى تحديد فيه يتم الذي

document .

STATIC DOCUMENT

Boldface tags

Effect of boldface tags

Dynamic document using CGI

Dynamic document using server-site script

Dynamic documents are sometimes referred to as server-site dynamic documents

Active document using Java applet

Active document using client-site script

Active documents are sometimes referred to as client-site dynamic documents

2: Application Layer 12

WEB &HTTP ال من مجموعة على تحتوي ويب صفحة .objectsكل الobjects تكون ان  HTML file, JPEG image, Javaيمكن

applet, audio file…, على تحتوي الويب على base HTML-fileصفحة يحتوي

ال من االخرى .objectsعدد كلobjects عنوان .URLله

Example URL:

www.someschool.edu/someDept/pic.gif

host name path name

13

HTTP HYPERTEXT TRANSFER PROTOCOL في يعمل برتكول عن عبارة

. التطبيق طبقة The Hypertext Transfer

Protocol (HTTP) is a protocol used mainly to access data on the World Wide Web.

client/server modelclient: browser that requests, receives, “displays” Web objects

server: Web server sends objects in response to requests

PC runningExplorer

Server running

Apache Webserver

Mac runningNavigator

HTTP request

HTTP re

quest

HTTP response

HTTP re

sponse

WEB COMMUNICATION

Internet

Get http://www.google.com/index.html

HTTP Request:

HTTP Reply

Client: browser (Firefox) on local computer

Web server: apache on www.google.com

HTTP VS HTML

HTML:  hypertext markup languageDefinitions of tags that are added to Web documents to control their appearance

HTTP:  hypertext transfer protocolThe rules governing the conversation between a Web client and a Web server 

16

HTTP OVERVIEW (CONTINUED)Uses TCP:

الclients بانشاء serverلل TCP connectionيقومال .80رقم portفي

الServer ال اليه TCP connectionيقبل وردت التيال . clientمن

ال ويعتبر HTTPرسائل المتصفح بين تبادلها يتمHTTP client ويعتبر الويب HTTP serverومخدم

ال اغالق يتم ذلك TCP connectionبعد

HTTP transaction

HTTP is “stateless” الserver لالتصاالت معلومات اي علي يحتوي ال

لل .clientsالسابقة

النوع من ألنه , statefullالبرتكوالت معقدة تعتبرالسابقة . االتصاالت مع التعامل يتم ان يجب

if server/client crashes, their views of “state” may be inconsistent, must be reconciled

HTTP OVERVIEW (CONTINUED)

19

HTTP CONNECTIONSNonpersistent HTTPAt most one object is sent over a TCP connection.

HTTP/1.0 uses nonpersistent HTTP

Persistent HTTPMultiple objects can be sent over single TCP connection between client and server.

HTTP/1.1 uses persistent connections in default mode

20

NONPERSISTENT HTTPSuppose user enters URL www.someSchool.edu/someDepartment/home.index

1a. HTTP client initiates TCP connection to HTTP server (process) at www.someSchool.edu on port 80

2. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index

1b. HTTP server at host www.someSchool.edu waiting for TCP connection at port 80.  “accepts” connection, notifying client

3. HTTP server receives request message, forms response message containing requested object, and sends message into its socket

time

2: Application L

ayer

21

NONPERSISTENT HTTP (CONT.)

5. HTTP client receives response message containing html file, displays html.  Parsing html file, finds 10 referenced jpeg  objects

6. Steps 1-5 repeated for each of 10 jpeg objects

4. HTTP server closes TCP connection. 

time

2: Application Layer 22

RESPONSE TIME MODELINGDefinition of RTT: time to send a small packet to travel from client to server and back.

Response time: one RTT to initiate TCP connection

one RTT for HTTP request and first few bytes of HTTP response to return

file transmission timetotal = 2RTT+transmit time

time to transmit file

initiate TCPconnection

RTT

requestfile

RTT

filereceived

time time

23

PERSISTENT HTTPNonpersistent HTTP issues: requires 2 RTTs per object OS must work and allocate host resources for each TCP connection

but browsers often open parallel TCP connections to fetch referenced objects

Persistent  HTTP server leaves connection open after sending response

subsequent HTTP messages  between same client/server are sent over connection

Persistent without pipelining: client issues new request only when previous response has been received

one RTT for each referenced object

Persistent with pipelining: default in HTTP/1.1 client sends requests as soon as it encounters a referenced object

as little as one RTT for all the referenced objects

2: Application Layer 24

HTTP REQUEST MESSAGE two types of HTTP messages: request, response HTTP request message:

ASCII (human-readable format)

GET /somedir/page.html HTTP/1.1Host: www.someschool.edu User-agent: Mozilla/4.0Connection: close Accept-language:fr

(extra carriage return, line feed)

request line(GET, POST, 

HEAD commands)

header lines

Carriage return, line feed 

indicates end of message

27.25

REQUEST AND RESPONSE MESSAGES

26

2: Application L

ayerHTTP REQUEST MESSAGE: GENERAL FORMAT

Request and status lines

28

UPLOADING FORM INPUT

Post method: Web page often includes form input Input is uploaded to server in entity body

URL method: Uses GET method Input is uploaded in URL field of request line:

www.somesite.com/animalsearch?monkeys&banana

METHODS

Status codes

Status codes (continued)

2: Application Layer 32

HTTP RESPONSE MESSAGE

HTTP/1.1 200 OK Connection closeDate: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ...

status line(protocolstatus codestatus phrase)

header lines

data, e.g., requestedHTML file

27.33

Header format

27.34

General headers

27.35

Request headers

27.36

Response headers

27.37

Entity headers

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

Example(1)

27.39

Example

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.

Example(2)

Example(2)

الcookie ب Lايضا webأو HTTP cookie وتعرفcookie ال عن browser cookieاو عبارة  smallهي

piece of data ال في وتخزن ويب موقع من ارسالها يتمbrowser. الموقع لذلك المستخدم تصفح اثناء

يقوم الموقع ذلك بتحميل المستخدم فيها يقوم مرة كلال بارسال معرفة serverلل cookieالمتصفح من ليتمكن

. للمستخدم السابقة النشاطات

Cookies

ال ان من الرغم فيروسات cookiesعلى نقل يمكنها التنزيل يمكنها قد malwareوال لكنها المستخدم جهاز في

المستخدم تتبع عمليات في يمكنها trackingتساعد حيثبواسطة historyمعرفة المواقع واستعراض التصفح

المستخدم .

Cookies can also store passwords and forms a user has previously entered, such as a credit card number or an address.

Cookies Cont.

44

USER-SERVER STATE: COOKIES

Many major Web sites use cookiesFour components:

1) cookie header line in the HTTP response message2) cookie header line in HTTP request message3) cookie file kept on user’s host and managed by user’s browser4) back-end database at Web site

Example: Susan access Internet always from same PC She visits a specific e-commerce site for first time When initial HTTP requests arrives at site, site creates a unique ID and creates an entry in backend database for ID

45

COOKIES: KEEPING “STATE” (CONT.)

client server

usual http request msg

usual http response +Set-cookie: 1678

usual http request msgcookie: 1678

usual http response msg

usual http request msgcookie: 1678

usual http response msg

cookie-specificaction

cookie-spectificaction

servercreates ID

1678 for user

entry in backend

database

access

acce

ss

Cookie file

amazon: 1678ebay: 8734

Cookie file

ebay: 8734

Cookie file

amazon: 1678ebay: 8734

one week later:

46

COOKIES (CONTINUED)

What cookies can bring: authorization shopping carts recommendations user session state (Web e-mail)

Cookies and privacy: cookies permit sites to learn a lot 

about you you may supply name and e-mail 

to sites search engines use  redirection & 

cookies to learn yet more advertising  companies  obtain info 

across sites

47

WEB CACHES (PROXY SERVER)

user sets browser: Web accesses via  cache

browser sends all HTTP requests to  cache object in cache: cache 

returns object  else cache requests object 

from origin server, then returns object to client

Goal: satisfy client request without involving origin server

client

Proxyserver

client

HTTP request

HTTP re

quest

HTTP response

HTTP re

sponse

HTTP re

quest

HTTP re

sponse

origin server

origin server

2: Application Layer

48

MORE ABOUT WEB CACHING Cache acts as both client and server Typically cache is installed by ISP (university, company, residential ISP)

Why Web caching? Reduce response time for client request. Reduce traffic on an institution’s access link. Internet dense with caches enables “poor” content providers to effectively deliver content (but so does P2P file sharing)

2: Application Layer

49

CONDITIONAL GET

Goal: don’t send object if cache has up-to-date cached version

cache: specify date of cached copy in HTTP requestIf-modified-since: <date>

server: response contains no object if cached copy is up-to-date: HTTP/1.0 304 Not Modified

cache server

HTTP request msgIf-modified-since:

<date>

HTTP responseHTTP/1.0

304 Not Modified

object not 

modified

HTTP request msgIf-modified-since:

<date>

HTTP responseHTTP/1.0 200 OK

<data>

object modified

Thank You