0% found this document useful (0 votes)
33 views13 pages

Project 1

The document outlines a project to implement a simple web client and server using a restricted subset of HTTP and socket programming. It explains the structure of HTTP requests and responses, including the request line and headers, and provides examples of HTTP headers and requests. The project consists of several parts, including building and configuring the minet stack, creating an HTTP client, and developing various types of HTTP servers.

Uploaded by

rishi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views13 pages

Project 1

The document outlines a project to implement a simple web client and server using a restricted subset of HTTP and socket programming. It explains the structure of HTTP requests and responses, including the request line and headers, and provides examples of HTTP headers and requests. The project consists of several parts, including building and configuring the minet stack, creating an HTTP client, and developing various types of HTTP servers.

Uploaded by

rishi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Project 1

Web client and server

Ashish Gupta
CS 340
Jan 2004
Project Goals
• Implement a simple WWW client and server
– Examples
• Use a restricted subset of HTTP
• Use socket programming
• To give you experience with HTTP and sockets
programming
HTTP Protocol

Sockets
HTTP Usage
• HTTP is the protocol that supports
communication between web browsers and
web servers.

• A “Web Server” is a HTTP server

• Most clients/servers today speak version 1.1,


but 1.0 is also in use.
Request - Response
• HTTP has a simple structure:
– client sends a request
– server returns a reply.
HTTP 1.0+ Request Request-Line
Headers
.
.
.
• Lines of text (ASCII). blank line

Content...

• Lines end with CRLF “\r\n”

• First line is called “Request-Line”


Request Line
Method URI HTTP-Version\r\n

• The request line contains 3 tokens (words).

• space characters “ “ separate the tokens.

• Newline (\n) seems to work by itself (but the


protocol requires CRLF)
The Header Lines
• After the Request-Line come a number
(possibly zero) of HTTP header lines.

• Each header line contains an attribute name


followed by a “:” followed by a space and the
attribute value.

The Name and Value are just text.


Headers
• Request Headers provide information to the
server about the client
– what kind of client
– what kind of content will be accepted
– who is making the request

• There can be 0 headers (HTTP 1.0)


• HTTP 1.1 requires a Host: header
Example HTTP Headers

Accept: text/html

Host: [Link]

From: neytmann@[Link]

User-Agent: Mozilla/4.0

Referer: [Link]
Example GET Request
GET /~ychen/[Link] HTTP/1.1
Accept: */*
Host: [Link]
User-Agent: Internet Explorer
From: cheater@[Link]
Referer: [Link]
There is a blank line here
Well Known Address
• The “well known” TCP port for HTTP servers is
port 80.

• Other ports can be used as well...


Four parts
• 0: Get build , configure and run the minet stack
• 1: HTTP Client
• 2: Connection-at-a-time HTTP Server
• 3: Simple select-based Multiple-connection-at-
a-time server
• 4: Complex …. ( Extra Credit )

You might also like