Lecture1 HTTP
Lecture1 HTTP
Lecture1 HTTP
Ralph Moseley
14/03/2012 Developing Web Applications
(C) 2007 John Wiley & Sons Ltd. www.wileyeurope.com/college/moseley
WWW
The World Wide Web (WWW) was developed by Tim Berners-Lee and other research scientists at CERN, the European center for nuclear research, in the late 1980s and early 1990s. WWW is a client-server model and uses TCP connections to transfer information or web pages from server to client. WWW uses a Hypertext model. Hypertext allows interactive accesses to a collection of documents. Documents can hold Text (hypertext), Graphics, Sound, Animations, Video Documents are linked together Non-distributed all documents stored locally (e.g on CD-Rom). Distributed documents stored at remote servers on the Internet.
14/03/2012 Developing Web Applications
(C) 2007 John Wiley & Sons Ltd. www.wileyeurope.com/college/moseley
14/03/2012
Rather than having a fixed representation for every browser, pages are formatted with a mark up language. This allows browser to format page to fit display. Different browsers can display pages in different ways. This also allows text-only browser to discard graphics for example. Standard is called HyperText Markup Language (HTML).
14/03/2012 Developing Web Applications
(C) 2007 John Wiley & Sons Ltd. www.wileyeurope.com/college/moseley
WWW HTML
HTML specifies Major structure of document Formatting instructions for browsers to execute. Hypertext links Links to other documents Additional information about document contents Two parts to document: Head contains details about the document. Body contains the information/content of the document. Each web page is represented in ASCII text with embedded HTML tags that give formatting instructions to the browser. Formatted section begins with tag, <TAGNAME> End of formatted section is indicated by </TAGNAME>
14/03/2012
<img SRC=GCD.gif" height=35 width=30> The above line would insert the image in the file GCD.gif into any web page. Image must be in format known to browser, e.g., Graphics Interchange Format (GIF), Joint Photographic Experts Group (JPEG), Bitmap etc
14/03/2012
WWW Style The layout and format of an HTML document can be simplified by using CSS (Cascading Style Sheets)
<html> <head> <style type="text/css"> body {background-color: yellow} h1 {background-color: #00ff00} h2 {background-color: transparent} p {background-color: rgb(250,0,255)} </style> </head>
<body>
<h1>This is header 1</h1> <h2>This is header 2</h2> <p>This is a paragraph</p> </body> </html>
14/03/2012
Computer name can be DNS name or IP address. TCP port is optional (http uses port 80 as its default port). document_name is path on server to web page (file).
14/03/2012
10
14/03/2012
11
12
Each separate item in a web page (e.g., pictures, audio) require a separate TCP connection. HyperText Transport Protocol (HTTP) specifies commands that the client (browser) issues to the server (web server) and the responses that the server sends back to the client.
14/03/2012 Developing Web Applications
(C) 2007 John Wiley & Sons Ltd. www.wileyeurope.com/college/moseley
13
14
14/03/2012
15
Serving a Page
User of client machine types in a URL
server (Apache)
14/03/2012
16
Serving a Page
Server name is translated to an IP address via DNS
client (Netscape) http:// www.smallco.com /index.html server (Apache)
192.22.107.5
14/03/2012
17
Serving a Page
Client connects to server using IP address and port number
client (Netscape) http://www.smallco.com/index.html
192.22.107.5 port 80
server (Apache)
192.22.107.5
14/03/2012
18
Serving a Page
Client determines path and file to request
server (Apache)
14/03/2012
19
Serving a Page
Client sends HTTP request to server
server (Apache)
14/03/2012
20
Serving a Page
Server determines which file to send
client (Netscape)
server (Apache)
http://www.smallco.com/index.html
14/03/2012
21
Serving a Page
Server sends response code and the document
client (Netscape) HTTP/1.1 200 OK Content-type: text/html [contents of index.html] server (Apache)
http://www.smallco.com/index.html
14/03/2012
22
Serving a Page
Connection is broken
client (Netscape)
server (Apache)
14/03/2012
23
HTTP
HTTP is
Designed for document transfer Generic
not tied to web browsers exclusively can serve any data type
Stateless
no persistant client/server connection
14/03/2012
24
14/03/2012
25
26
audio/mpeg
application/octetstream
.mp3
.exe
14/03/2012
27
14/03/2012
28
broswer creates a HTTP GET Request message and sends it over a TCP connection to the web server. In the above case, the HTTP GET Request message would be
GET /Recreation/Sports/Soccer/index.html HTTP/1.0 User-Agent: InternetExplorer/5.0 Accept: text/html, text/plain, image/gif, audio/au \r\n
14/03/2012
29
Delimiter Carriage return User data e.g. contents of Line feed completed form
30
Delimiter
The Status Line gives information about the success of the previous HTTP Request
14/03/2012
Success Redirection Document has been moved Client Error Bad Request, Unauthorised, Not found Server Error Internal Error, Service Overloaded
Developing Web Applications
(C) 2007 John Wiley & Sons Ltd. www.wileyeurope.com/college/moseley
31
If a user returns to previous HTML document, then this could require downloading the document from the server again. A browser can hold copies of recently visited pages. This avoids having to download pages again. An organisation can use a HTTP proxy that caches documents for multiple users. Thus improving the speed at which pages can be displayed on each users computer.
14/03/2012 Developing Web Applications
(C) 2007 John Wiley & Sons Ltd. www.wileyeurope.com/college/moseley
32
Proxy server:
14/03/2012
Developing Web Applications (C) 2007 John Wiley & Sons Ltd.
33
html interpreter
Controller
optional plugins
D i s p l a y D r i v e r
HTTP client
Other client
34
14/03/2012
35
Other Protocols
FTP - File Transfer Protocol
The Internet began development in the 1960s. Moving a file from one computer to another computer required some form of removable medium (floppy disk or tape). People required a protocol to reliably transfer files between any two computers connected to the Internet. Why not use HTTP? The HTTP protocol was developed in the late 1980s and the early 1990s after 10 years of FTP developed in 1971.. HTTP provides a poor authentication mechanism of users of the protocol. HTTP doesnt easily allow files to be sent in both directions. HTTP doesnt allow files to be downloaded in separate stages.
14/03/2012 Developing Web Applications
(C) 2007 John Wiley & Sons Ltd. www.wileyeurope.com/college/moseley
36
14/03/2012
Developing Web Applications (C) 2007 John Wiley & Sons Ltd.
37
FTP - Functions
The main function of FTP was to allow the sharing of files across the Internet. It has CHMOD permission for read, write and Execute. Other functions included Allowing computer users to use computers remotely. Hiding file storage differences from the user. The format that files are stored on a Macintosh are different from a PC which in turn are different from a Unix workstation. Different length filenames also have to be accommodated. Transfer of file data between computers has to be done reliably and efficiently. FTP should also allow transfer of very large files to be done in stages.
14/03/2012 Developing Web Applications
(C) 2007 John Wiley & Sons Ltd. www.wileyeurope.com/college/moseley
38
FTP
FTP is a client/server program An FTP client program enables the user to interact with an ftp server in order to access files on the ftp server computer. Client programs can be:
Simple command line interfaces. E.g. MS-Dos Prompt C:\ ftp ftp.maths.tcd.ie Integrated with Web browsers, e.g. Netscape Navigator, Internet Explorer.
FTP provides similar services to those available on most filesystems: list directories, create new files, download files, delete files. FTP uses TCP connections and the default server port for FTP is 21.
14/03/2012 Developing Web Applications
(C) 2007 John Wiley & Sons Ltd. www.wileyeurope.com/college/moseley
39
Interactive transfer
User starts ftp program User can interactively list contents of directories, transfer files, delete files etc. User can find and transfer files immediately Quick feedback in case of mistakes, e.g., spelling errors
14/03/2012 Developing Web Applications
(C) 2007 John Wiley & Sons Ltd. www.wileyeurope.com/college/moseley
40
Description Open connection to computer List Directory contents Change to another directory Change to binary transfer, used for downloading executables. Download a file from remote computer Upload a file to the remote computer Start download of multiple files Start upload of multiple files
14/03/2012
41
FTP - Checkpointing
A data transfer may be aborted after only transferring part of a file.
This could be due to the client or the server crashing, the TCP connection being broken due to congestion, phone hanging up during dial up connection.
FTP allows the file transfer from where the transfer was stopped, no need to re-transfer part of file. FTP achieves this by sending restart markers between the server and the client. Restart markers are saved in a restart file by the client. Client sends restart marker when it wants to continue the transfer of a previously stopped transfer.
14/03/2012
42