Download Understanding HTTP Protocol, Proxy Servers and COSC 6377 Term Project in Fall 2000 and more Study Guides, Projects, Research Computer Systems Networking and Telecommunications in PDF only on Docsity!
HTTP Protocol, Proxy,
and
COSC 6377 Term Project Tutorial
T. Mark Huang
http://www.cs.uh.edu/~jsteach/cosc6377/
The Web: the http protocol
http: hypertext transfer
protocol
- Web’s application layer protocol
- client/server model
- client: browser that requests, receives, “displays” Web objects
- server: Web server sends objects in response to requests
- http1.0: RFC 1945, May 1996
- http1.1: RFC 2068, Jan. 1997
PC running Explorer
Server running NCSA Web server
Mac running Navigator
http request
http request
http response
http response
COSC 6377, Fall 2000 3
The http protocol: more
http: TCP transport service:
- client initiates TCP connection (creates socket) to server, port 80
- server accepts TCP connection from client
- http messages (application-layer protocol messages) exchanged between browser (http client) and Web server (http server)
- TCP connection closed
URL (Uniform Resource Locator)
has three parts: scheme, host name (w/port), and path name:
http://www.someSchool.edu:port/someDept/pic.gif
http example
Suppose user enters URL
http://www.someSchool.edu/someDepartment/index.html
1a. http client initiates TCP connection to http server (process) at www.someSchool.edu. Port 80 is default for http server.
- http client sends http request message (containing URL) into TCP connection socket
1b. http server at host www.someSchool.edu waiting for TCP connection at port 80. “accepts” connection, notifying client
- http server receives request message, forms response message containing requested object (someDepartment/home.index), sends message into socket
time
(contains text, references to 10 jpeg images)
COSC 6377, Fall 2000 7
http message format: request
- two types of http messages: request , response
- http request message:
- ASCII (human-readable format)
GET http://www.uh.edu/index.html HTTP/1. User-agent: Mozilla/4. Accept: text/html, image/gif,image/jpeg Accept-language:fr
(extra carriage return, line feed)
request line (GET, POST, HEAD commands)
header lines
Carriage return, line feed indicates end of message
http request message: general format
COSC 6377, Fall 2000 9
http message format: respone
HTTP/1.0 200 OK
Date: 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 (protocol status code status phrase)
header lines
data, e.g., requested
html file Common Status Code:
200 OK
301 Moved Permanently 400 Bad Request 403 Forbidden 404 Not Found
HTTP Proxy
deals with HTTP servers
(web servers) on behalf
of HTTP clients
(browsers).
proxy servers, which
relay approved client
requests on to real
servers, and relay
answers back to clients.
client
Proxy server
client
http request http response
http request http response
http request http response http request http response
origin server
origin server
COSC 6377, Fall 2000 13
fork() v.s. select()
• to handle multiple connections
• fork(): start a new process to handle each
request. Easy to implement, but not scale well
and require interlocking for shared resource.
• select(): one process handles all requests.
Scale well and do not require interlocking for
shared resource, but more complex to
implement (may need to build state diagram).
Sample programs
Located in ~jsteach/www/cosc6377/proxy/skel/
• sample1.c - clear channel echo TCP client
• sample2.c & sample2-sig.c - clear channel echo
TCP server
For above client and sever programs, client sends whatever input from console to server , and server sends whatever input from console to client. You can use client to mimic browser and sever to mimic web server, and your proxy runs in-between them.
• pipe.cc - pipe(2) example
• http.cc - proxy filter library sample
Assignment
• Due midnight, Tu., Nov. 21st, 2000
• Start immediately!!
• 20% of your final grade
• Group project: 1 or 2 people
• Submission: detail will be posted on the web
• Turn in all required files (*.c, Makefile, & Readme)
• Read FAQ in the project web page
the newsgroup
• MOSS: Measure Of Software Similarity (UC Berkeley)