CSE 342: Project 1 - Simple HTTP/1.0 Client and Server

For this assignment you will want to refer to the HTTP/1.0 RFC.

  1. Due Tuesday 22 September 2009 via BlackBoard

    Create an HTTP echo server. You might want to modify the provided tcpserver code (C version) to respond like a web server. (Actually, you do not need to use all or even any of the provided tcpserver code, as some of it may be inappropriate for this assignment.) That is, when a connection is made, read the request and generate a valid HTTP/1.0 response, which for this project is a status line 200, a content text/plain header, a blank line, and then content. The content returned should just be the exact request header data sent by the client. Demonstrate to yourself (and to us) that it works by printing to the screen the complete response it gives when you send a request from your browser.

    So, for example, if you are running your server on ariel on port 2345, you would specify in your browser the URL: http://ariel.cse.lehigh.edu:2345/anything and in your browser you should see something like:

      GET /anything HTTP/1.1
      Host: ariel.cse.lehigh.edu:2345
      User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.4 i586)
      Accept: */*
      
    On the shell where your server is running you would want to see the headers that you sent to the client, too, so you would see:
      HTTP/1.0 200 OK
      Content-Type: text/plain
      
      GET /anything HTTP/1.1
      Host: ariel.cse.lehigh.edu:2345
      User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.4 i586)
      Accept: */*
      

    Your server should be able to accept multiple connections in a row (but not simultaneously). Make certain that it works using the firefox web browser in the Sun lab (since we'll ask you to do that when you demonstrate it). Use this server (or the sample executable described at the bottom of this page) to test/debug your implementation of simpleget, as described below.

  2. Due Tuesday 29 September 2009 via BlackBoard

    Write a simpleget client. GNU Wget is a freely available network utility (installed on the Suns) to retrieve files from the World Wide Web, using HTTP (HyperText Transfer Protocol) and FTP (File Transfer Protocol), two of the most widely used Internet protocols. It has many useful features to make downloading easier. You can read lots more about wget.

    Write simpleget in C, which implements a subset of wget. It takes one argument -- the URL to retrieve. Simpleget retrieves that URL and sends it to STDOUT. A user would employ redirection to save the contents in a file, e.g., "./simpleget http://www.cse.lehigh.edu/ > cse-home.html".

    You need to parse the URL, connect to the appropriate host and port, generate an HTTP/1.0 GET request, and specify Host: and User-agent: headers. Discard response headers and write content to stdout, unless there is an HTTP error, in which case write everything, including headers to stdout. (Recall that you know how to perform DNS lookups from Lab 2; you had practice making TCP connections in Lab 3.) Make certain that you don't code constants into your program (such as the host and port number) but instead get them from the argument so that your program can work on regular websites as well as your echo server from step 1 without recompiling.

    As you may recall from lecture, the Host: header is needed for cases in which multiple web sites (e.g., different domain names) are on the same machine using the same IP address. With the Host: header, the web server can figure out which web site you really wanted. The User-agent: header should reflect a name you have chosen for your program and your email address so that people can contact you if your program misbehaves.

    Expand your simpleget code to handle HTTP redirects automatically. That is, it should follow redirection responses to the ultimate destination, and return that content.

Sample implementations of these two programs are available. If you would like to see a working version of each of these programs, you can copy ~brian/cse342/bin/echoserver-x86-solaris and ~brian/cse342/bin/simpleget-x86-solaris if you are using one of the modern (x86) Suns, or ~brian/cse342/bin/echoserver and ~brian/cse342/bin/simpleget for the older sparc Suns.

You need to:

Grading will likely be as follows: In addition, you will lose points if


Last modified: 14 September 2009