You are on page 1of 21

.

- ,

(World Wide Web)


WWW (World Wide Web),
. World Wide Web
1989 Tim Berners Lee
CERN .
,
( , .)
.
-
( ) HTTP
(HyperText Transfer Protocol), .
HTTP?
Tim Berners Lee 1991 , HTTP :

( )

(www) .. HTTP RFC2616.


()

HTTP:

HTTP

1.0

(RFC1945),

http://www.w3.org/Protocols/rfc2616/rfc2616.txt).

Glava 5 - 1

HTTP

1.1

(RFC2068,

.- ,

.
.. hypermedia (hyper
, media ).
- TCP/IP, 80.

(browser), : Internet Explorer,


Netscape, Opera, Firefox

, : IIS (Internet
Information Services), Apache.


HTML (HyperText Markup Language).
Web browser ( ) Web
. Web browsers HyperText Markup
Language (HTML) HTTP Web .

, .

5.1 HTTP (Hypertext Transfer Protocol)


HTTP : HTTP 1.1 RFC 2616;
HTTP 1.0 - RFC 1945. HTTP
HTML (Hypertext Markup Language) . HTML
tag . Hypertext

. ,
, , JAVA applets .
HTTP - 4 :

TCP ( ) , 80

TCP

HTTP ( ) browser- (HTTP


) (HTTP )

TCP

Glava 5 - 2

.- ,

HTTP TCP/IP TCP/IP


80, .
, ,

, HTTP 1.0 ( HTTP).
HTTP 1.1 RFC 2616, o
TCP
, .
(persistant). HTTP HTTP
.
- URI (Uniform Resource
Identifier). URI web a URL
(Uniform Resourse Locator) URN (Uniform Resourse Name).
URL: http://www.lokacija.mk/tk/

: http

- : www.lokacija.mk

: /tk/strana.html

http URL:
http: // imenahost [:porta] / pateka [; parametri] [? query]
URL
() ( 80)
(:) (.. ).

.. query (?)
. :
http://www.webserver.mk/login.html?username=toni&password=123&language=mk

Glava 5 - 3

.- ,

5.2 HTML
Hyper Text Mark-Up Language (HTML)
( ) .
(mark-up), HTML
. HTML
, :
( web
browser ) .
HTML ,
HTML
. ,
browser
browser.
HTML browser .
HTML (tags)
.
HTML 5.1.
<HTML>
<HEAD>
<TITLE> HTML </TITLE>
</HEAD>
<BODY>
<P>
HTML
</BODY>
<HTML>
5.1 HTML ( )
<> (.. <tag>)
. HTML :

Glava 5 - 4

.- ,

(head) (body)
.
HTML HTML .
<HTML>, </HTML>.
HTML <!--
-->. :
<!-- -->
,
(title), (links)
URL n .

5.2.1 HTML
HTML ,
( ) (
) .. .
.
HTML ,
(template) .
5.2.
<HTML>
<HEAD>
<TITLE> </TITLE>
</HEAD>
<BODY>
<ADDRESS> , , (e-mail)</ADDRESS>
</BODY>
</HTML>
5.2 template.html

Glava 5 - 5

.- ,

(title)
HTML
. <title> </title> .
:
<TITLE> </TITLE>
(headers)

. .
, <H1> <H6> 1.

.
<H1> </H1>

.
, HTML () ,
.
:
<A 'Href=http://www.feit.ukim.edu.mk> </A>
href e URL , ( )
,
( ) browser-.
,
. HTTP
, HTTP .

Glava 5 - 6

.- ,

5.3 HTTP
, HTTP -
. ,
. TCP,
:

TCP ( ) , 80

TCP

HTTP ( ) browser- (HTTP


) (HTTP )

TCP
, HTTP stateless,

(request-) .
(browser-)
browser ( : ,

).
.
:
, gateway .

. ,
. Gateway-, ,
.
, (
/ IP ,
).
HTTP .
IP ( , 5,
HTTP ).

Glava 5 - 7

.- ,

, HTTP
.

5.3.1 HTTP
Web
Web Hiper Text
Transfer Protocol (HTTP). HTTP :

. HTTP .
,
.

Request/Response. ,
( ) HTTP
.

Stateless. HTTP
.

. Web
. HTTP
.

. HTTP
.
.

. ,
.
, HTTP

.

. HTTP
proxy server,
.
Glava 5 - 8

.- ,

5.3.2 HTTP
FTP,
.
1.1 1999 .

. ,
.
,
, .
,
, .
.
, Common
Gateway Interface (CGI ) Web .

. , HTTP :

(persistent)

TCP ( ).

HTTP/1.1 default

(non-persistent)

TCP .

HTTP/1.0 nonpersistent HTTP

5.3.3 - RRT
HTTP
HTTP , . HTTP
request ( , ,
, : Word )
Glava 5 - 9

.- ,

response , .
RTT (Round Trip Time) HTTP 5.3.

TCP

RTT

file

RTT

5.3 RTT HTTP


RRT: .
HTTP (response time):

RTT TCP

RTT HTTP request- HTTP response

= 2*RTT + ( )
, RTT
.

Glava 5 - 10

.- ,

. :
500 kbit/s, 5 kB :
(5 KB * 8 bit/Byte) / (500 kbit/s) = 16 usec

5.4 HTTP
HTTP
Web Web .
, - (TCP).
, (
), HTTP ,
.
.
,
.

. URL,
DNS- hostname
IP , .
, Web
.
HTTP GET
,
URL. .

.
GET
URL- HTTP . :
GET http://www.feit.ukim.edu.mk/test/ HTTP/1.1

Glava 5 - 11

.- ,

TCP , URL,
:
GET /test/ HTTP/1.0
, HTTP : request () response ().
,
.
HTTP .
(request) (response).

5.4.1 HTTP
HTTP (.. ) email
, , email
-
. , HTTP :

: HTTP (request)
(response).

: HTTP :
- (general header);
- (request header);
- (response header);
- (entity header).

:
, .
.

5.4.2
HTTP
HTTP 1.0 HTTP 1.1. GET

Glava 5 - 12

.- ,

. HTTP
:

GET: (
: )
URI.

HEAD:
( )
.

POST: (browser-)
( :
).

PUT: post
URI ( : ).

DELETE:
URI. ,
(
) .

TRACE:
() .

5.4.3
response ( )
.
.

en (1xx):
. :
100
101 switching protocols

Glava 5 - 13

.- ,

(2xx):
, . :
200
202

(Redirection, 3xx):
. :
302
305

(4xx). :
400
404

(5xx). :
500
503
.


.
HTML .
head
. <H1> </H1>
Bad Request ,
:

Bad Request
Your browser sent a request that this server could not understand.

5.4.4 HTTP
,
, E-mail ( RFC 822).
, .
5.4
. , MIME email, ..
Glava 5 - 14

.- ,

Content-Type Content-Encoding MIME,


.
(Header)

Content-Length

Content-Type

Content-Encoding

Content-Language

5.4

HTTP

HTTP/1.1 200 OK
Date: Fri, Wed, 11 Apr 2007 12:11:13 GMT+01:00
Server: Apache/1.3.29 (FEIT)
Last-Modified: Wed, 11 Apr 2007 11:15:36 GMT+01:00
ETag: "58db37-89-407fb25f"
Accept-Ranges: bytes
Content-Length: 137
Connection: close
Content-Type: text/html
<html>
<body>
<p>Zdravo</p>
<img src=smiley.gif">
</body>
</html>
5.5 TP response

5.5 HTTP response ,


HTTP
. (HTTP 1.1),
, Connection:Close.

.
,
. ,
Glava 5 - 15

.- ,

.
.

5.4.5
HTTP ,
.

( ), ( jpeg
), (
) (
). :

().

. .
. ,
,
, .

. ,
. .

.
,
.
Accept
, .
, .
:

Glava 5 - 16

.- ,

Accept: text/html, text/plain, q=0.5, text/x-dxi, q=0.8


text/html,
text/plain.
.
q=1, q=0
. Accept
Content MIME . ,
:
Accept-Encoding:
Accept-Charset:
Accept-Language:
,
.

5.5 (caching)
:
, ,
. :
, , ,
. ,
, .

- ? ,

. ,

.
HTTP .

( ,
Glava 5 - 17

.- ,

, ,

).

a) Cache hit

Client

Cache
Object
Cache

Server

b) Cache miss

Client

Server
Object

Server
Object
Cache

Server

c) Cache reval/data hit


Freshness Check

Client

Cache
Object
Cache

Still Fresh
Server

5.6 HTTP
HTTP
.
(
) .

.
, .
,
.

, .
, -
,

Glava 5 - 18

.- ,

,
.
,

. ,


. ,
.

. ,
.
.
HTTP . ,
HTTP ,
,
.
,
,
,
. , HTTP


. Max-Forwards

. ,
Max-Forwards:1
.
.

5.6 Cookie
cookie? Cookie servlet browser.
, Servlet , Applet
browser-.

Glava 5 - 19

.- ,

cookies. Cookie-
browser response
( ). cookie
, cookie request
(, ). (..
browser-) cookies.

Cookie
amazon: 1678
ebay: 8734

http response +

Set-cookie: 1678
http request

cookie: 1678
http response

ID

1678

cookie

:
Cookie
amazon: 1678
ebay: 8734

http request

cookie: 1678
http response

ebay: 8734

http request

Cookie

cookie

5.7 cookie
Cookie :

cookie header line HTTP response

cookie header line HTTP request

cookie browser-

cookies? cookies,
.
cookies:

( : web-mail)

Glava 5 - 20

.- ,

Cookie ,
browser-
cookies. ,
email cookie.
cookie search .
cookie HTTP
response HTTP request
5.7. cookie
(browser-) HTTP request .

Glava 5 - 21