Communication with a Web Server Web Engineering � HTTP is based on TCP – to experiment with the protocol telnet can be used. Prof. Dr. Dr. h.c. mult. Gerhard Krüger, Albrecht Schmidt > telnet 129.13.170.1 80[RETURN] GET /index.html HTTP/1.0[RETURN] Universität Karlsruhe [RETURN] Fakultät für Informatik > telnet www.teco.edu 80[RETURN] Institut für Telematik HEAD /index.html HTTP/1.0[RETURN] [RETURN] Wintersemester 1999/2000 Prof. Dr. Dr. h.c. mult. Gerhard Krüger, Albrecht Schmidt: Web Engineering, WS00/01 Seite 1 Prof. Dr. Dr. h.c. mult. Gerhard Krüger, Albrecht Schmidt: Web Engineering, WS00/01 Seite 3 HTTP Transaction Client Server (Browser) user Request Web Engineering fetch Transaction 1 resource Response Analyzing the content Chapter 2: Foundation - Identifiers and Protocols (cont.) Request fetch Transaction 2 resource Response Prof. Dr. Dr. h.c. mult. Gerhard Krüger, Albrecht Schmidt: Web Engineering, WS00/01 Seite 2 Prof. Dr. Dr. h.c. mult. Gerhard Krüger, Albrecht Schmidt: Web Engineering, WS00/01 Seite 4
HTTP/0.9 HTTP/1.0 � GET method � simple, lightweight, fast, easy to implement � only an informational RFC, 1992-1996 [RFC1945] � message Types � Transfer of text documents (preferably HTML) � request (GET, HEAD, POST) � Not specified in a RFC � response [http://www.w3.org/Protocols/HTTP/HTTP2.html] � header fields http://www. teco.edu/index.html � variable number of fields DNS-lookup � Syntax: <field_name> ":" <field_value> � Transfer of meta information on the request, response, and content Protocol = http accept TCP connect � response codes <HTML> <HEAD> � status and error information connect TCP socket TCP-connection <TITLE>Titelseite</TITLE> GET /index.html </HEAD> � media types <BODY> � transfer of arbitrary resources, especially close TCP socket Inhaltsseite </BODY> � graphics, images, audio, video </HTML> � based on MIME (multipurpose internet mail extensions) Web Client close TCP connect � basic mechanism for access control and authentication Web Server Prof. Dr. Dr. h.c. mult. Gerhard Krüger, Albrecht Schmidt: Web Engineering, WS00/01 Seite 5 Prof. Dr. Dr. h.c. mult. Gerhard Krüger, Albrecht Schmidt: Web Engineering, WS00/01 Seite 7 DNS host name resolution HTTP/1.0 - scenario Root-Server http://www. teco.edu/index.html de ? com de DNS-lookup Protocol = http accept TCP connect DE -Server comp-c.de ? comp-a HTTP/1.0 200 OK comp-b Content-Type: text/html connect TCP socket comp-c <CR><LF> TCP connection <HTML> GET /index.html HTTP/1.0 <HEAD> comp -c.de cs.comp-c.de ? Accept: */* <TITLE>Page X</TITLE> shop </HEAD> <CR><LF> dep1 <BODY> cs close TCP socket Content is here ... close TCP connect www.cs.comp-c.de cs.comp-c.de Web Client ? client Query: www 1.2.3.4 Web Server Name server 1.2.3.5 www.cs.comp-c.de Server resolver Answer: 1.2.3.4 Prof. Dr. Dr. h.c. mult. Gerhard Krüger, Albrecht Schmidt: Web Engineering, WS00/01 Seite 6 Prof. Dr. Dr. h.c. mult. Gerhard Krüger, Albrecht Schmidt: Web Engineering, WS00/01 Seite 8
Document transfer (HTTP) I Document transfer (HTTP) III � GET Method � URL: http://www.teco.edu/lehre/webe/index.html Client Server � procedure at the client side Input: URL • Identify host name from the URL open Socket: (TCP, Host, Port) www.teco.edu send Request accept connection resolve the IP-Address GET /lehre/webe/index.html HTTP/1.0 read from Socket 129.13.170.1 CR+LF read from process request • Identify port number Socket, till method GET 80 (default) the Socket resource: Is closed /lehre/webe/index.html • open Socket (TCP) to 129.13.170.1 Port 80 send header • sent method over the Socket HTTP/1.0 200 OK send data CR+LF GET / lehre/webe/index.html HTTP/1.0 • Read from socket until the socket is closed by the server. close Socket <HTML> <HEAD>... • Result: header with status and the requested resource or an error message show content Prof. Dr. Dr. h.c. mult. Gerhard Krüger, Albrecht Schmidt: Web Engineering, WS00/01 Seite 9 Prof. Dr. Dr. h.c. mult. Ge rhard Krüger , Albrecht Schmidt: Web Engineering, WS00/01 Seite11 Document transfer (HTTP) II Tools I � GET Method � Program shows the request of the browser as web page: http://www.teco.edu:8080/ � URL: http://www.teco.edu/lehre/webe/index.html � procedure at the server side � Typical page: • A process on the machine 129.13.170.1 waits on Sorry Not HTTP-Methods supported! port 80 for a connection request Your Request: • If there is a request a connection is established, then: GET / HTTP/1.1 Accept: */* • read from socket to the first empty line Referer: • analyze the given request (extract method and http://www.teco.edu/lehre/webe/beispiele.html resource name) Accept-Language: en-us Accept-Encoding: gzip, deflate • Write status on the socket User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; • localize resource (e.g. File system), read the Windows NT; DigExt) Host: www.teco.edu:8080 resource and write it to the socket Connection: Keep-Alive • close the socket Cookie: SITESERVER=ID=fe340799f17c660e09e1f34c9dbf Prof. Dr. Dr. h.c. mult. Ge rhard Krüger , Albrecht Schmidt: Web Engineering, WS00/01 Seite10 Prof. Dr. Dr. h.c. mult. Ge rhard Krüger , Albrecht Schmidt: Web Engineering, WS00/01 Seite12
Tools II HTTP/1.0 Example � Program to build and send HTTP-Requests: � Request http://www.teco.edu/lehre/webe/beispiele/http.html Request Method GET /index.html HTTP/1.0 Accept: image/gif, image/x-xbitmap, image/jpeg, */* ---Open TCP connection to www.teco.edu:80 Accept-Language: de ---Request: Header Accept-Encoding: gzip GET /lehre/webe/ HTTP/1.1 Host: www.teco.edu User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT) Accept: */* blank line ( CRLF ) Connection: keep-alive ---End of Request ---Server Reply:------------- � Response HTTP/1.1 200 OK Date: Thu, 28 Oct 1999 10:29:07 GMT Server: Apache/1.2.1 Status HTTP/1.0 200 OK Keep-Alive: timeout=10, max=100 Server: ServerName Connection: Keep-Alive Content-Type: text/html Header Transfer-Encoding: chunked Content-Length: 80 Content-Type: text/html blank line ( CRLF ) <HTML> b76 Data <html> <TITLE> ... ... Prof. Dr. Dr. h.c. mult. Ge rhard Krüger , Albrecht Schmidt: Web Engineering, WS00/01 Seite13 Prof. Dr. Dr. h.c. mult. Ge rhard Krüger , Albrecht Schmidt: Web Engineering, WS00/01 Seite15 Documents contain Resources I tools III � reply of the servers HTTP/1.0 200 OK � programs to analyze the traffic in a network: Content-Type: text/html tcpdump (Unix/Linux), Content-Length: 3213 etherpeak (Mac) [www.wildpackets.com], <html> <head> Systems Management Server (Windows NT) <title>Oracle Corporation - Home</title> ... </head> � works only in superuser mode <body bgcolor="#ffffff" link="#000000" vlink="#ff0000"> ... � abuse is illegal! <INPUT NAME=q size=10 maxlength=800 VALUE=""><INPUT TYPE="image" src="/templates/images/search_btn.gif" width=36 height=18 value="go" border=0> ... <a href="/html/dev_it.html"> <img src="/images/devit_off.gif" alt="Developers/IT" border=0></a> ... <img src="/images/clear_dot.gif" width=50 height=1> ... </body> </html> Prof. Dr. Dr. h.c. mult. Ge rhard Krüger , Albrecht Schmidt: Web Engineering, WS00/01 Seite14 Prof. Dr. Dr. h.c. mult. Ge rhard Krüger , Albrecht Schmidt: Web Engineering, WS00/01 Seite16
Documents contain Resources I Documents contain Resources III � reply of the servers HTTP/1.0 200 OK Content-Type: text/html Content-Length: 3213 <html> <head> <title>Oracle Corporation - Home</title> ... � images </head> <body bgcolor="#ffffff" link="#000000" vlink="#ff0000"> � background ... <INPUT NAME=q size=10 maxlength=800 VALUE=""><INPUT � buttons TYPE="image" src="/templates/images/search_btn.gif" width=36 height=18 value="go" border=0> � music ... <a href="/html/dev_it.html"> � audio <img src="/images/devit_off.gif" alt="Developers/IT" border=0></a> ... <img src="/images/clear_dot.gif" width=50 height=1> ... </body> </html> Prof. Dr. Dr. h.c. mult. Ge rhard Krüger , Albrecht Schmidt: Web Engineering, WS00/01 Seite17 Prof. Dr. Dr. h.c. mult. Ge rhard Krüger , Albrecht Schmidt: Web Engineering, WS00/01 Seite19 Documents contain Resources II Documents contain Resources IV Client Server (Browser) URL Request load resource (HTML) analyze Response � images Request image 1 load resource � background Response image 2 Request � buttons load resource Response ... � music ... ... � audio image n Request load resource Response Prof. Dr. Dr. h.c. mult. Ge rhard Krüger , Albrecht Schmidt: Web Engineering, WS00/01 Seite18 Prof. Dr. Dr. h.c. mult. Ge rhard Krüger , Albrecht Schmidt: Web Engineering, WS00/01 Seite20
Recommend
More recommend