Web Essentials
C L I E N T, S E RV E R A N D
C O M M U N I C AT I O N
Client-Server Model
A file named
[Link]
Client Internet vtop Server
[Link]
HTTP: Hypertext Transport Protocol
HTTP is a form of communication protocol which specifies how web clients and servers should
communicate.
The basic structure of HTTP follows a request-response model.
A client always initiates a request message to the server; the server generates a response message.
HTTP:hyper text transfer protocol
The hypertext transfer protocol (HTTP) was developed by Tim Berners-Lee in 1991
• HTTP was designed to transfer pages between machines
• The client (or Web browser) makes a request for a given page and the Server is responsible for
finding it and returning it to the client
• The browser connects and requests a page from the server
• The server reads the page from the file system, sends it to the client and terminates the
connection
HTTP Request Message
Every HTTP request message has the same basic structure:
◦ Start Line (request method, URI, HTTP version)
◦ Header field(s) (one or more)
◦ Blank line
◦ Message body (optional)
GET http:/tian/public_html/[Link] HTTP/1.1
host: [Link]
HTTP Request Method
GET and POST are the two methods used to transfer data from client to server in HTTP protocol
GET: adds the request to the URL and sends it to server
POST: send the request to the server through a request body in the header.
More Differences
HTTP Header Fields
The Host header field is required in every HTTP/1.1 request message.
Three major header fileds:
◦ Host: [Link]
◦ User-agent: Mozilla/5.0 (Windows)
◦ Accept: text/html, application/xml (MIME types)
◦ Content types that are acceptable for the response
Example of HTTP Request Message
Try to retrieve the file at
[Link]
GET /~tian/public_html/[Link] HTTP/1.1
Host: [Link]
User-Agent: Mozilla9.0 (Windows)
Accept: text/html
HTTP Response Message
Every HTTP response message has the same basic structure:
◦ Status Line (HTTP version, status code, Reason Phrase)
◦ Header field(s) (one or more)
◦ Blank line
◦ Message body (optional)
HTTP/1.1 200 OK
HTTP/1.1 404 NOT FOUND
IP address and Domain Name
Every computer on the Internet has an IP address such as [Link]
Humans find it easier to refer to computers by names, such as [Link]. This is called
host/domain name.
DNS (Domain Name Service) provides a mechanism for mapping back and forth between IP
addresses and host names.
Client-Server Communication
What is the IP address of
“[Link]”
Client DNS
[Link]’s IP
address is
[Link]
HTTP Request
HTTP Response
Yahoo
Server
Web Client
Web client is a software that accesses a web server by sending an HTTP request
message and processing the resulting HTTP response.
Web Browser is a typical web client.
◦ IE, Firefox, Safari, etc
Browser-Wars
◦ [Link]/wiki/Browser_wars
◦ Each company trying to add features and performance to its browser in order to
increase its market share.
Server
The primary feature of every web server is to accept HTTP request from web
client and return an appropriate resource (if available) in the HTTP response.
1. Wait for connection requests from a client.
2. Receive an HTTP request.
3. Finding the requested file and creates an HTTP response that contains the file
in the body of the response message.
World wide web
The World Wide Web (WWW), commonly known as the Web, is an information system where
documents and other web resources are stored.
The documents are identified by Uniform Resource Locators (URLs, such as
[Link]
The URLs may be interlinked by hypertext, and are accessible over the Internet.
The resources of the WWW may be accessed by users by a software application called a web
browser.
Next Class
History of HTML
Basic elements of HTML5
Write your first web page in HTML5