Your assignment is to construct an HTTP client using the basic socket
calls. The program must accept as input a command line argument
that contains a URL of the form:
http://machinename[:portnum]/pathname.
The part in [] is optional. The machinename
part may be a hostname or a numeric dotted decimal value, such as
157.182.194.28. The pathname portion may be any pathname.
Invalid URLs that do not match this description should generate
some informative error message and not be processed.
Valid URLs should cause the program to attempt to retrieve the URL from the machine specified. Informative error messages should exist for connection failures and hostname lookup problems.
The program should use the HTTP protocol GET request to
retrieve the data. For all valid URLs, the program should interpret the
header and display it in a readable form. For the contents of HTML
URLs, the program must print out a list of the URLs embedded in the
data. Other URL contents can be ignored.
Errors from web servers should be formatted and displayed in an informative and readable form.
http_client http://byron.csee.wvu.edu/
should produce output similar to this:
Response Status: 200 "OK"
Server Information: Microsoft-PWS 3.0 (HTTP 1.0)
Content: text/html, 456 bytes, no encoding
Last Modified: Wed, 21 Jan 1998 16:10:10 GMT
Embedded URLs:
http://www.wvu.edu
http://www.cs.wvu.edu
http://www.cs.wvu.edu/~tmont
HTTP 1.0 Specification at http://www.w3.org/pub/WWW/Protocols/HTTP/1.0/spec.html
For extra credit, write a HTTP server that understands the HTTP 1.0
GET and HEAD requests.