Due Nov. 14, 2025 by email to the teaching assistant. This assignment gives you a chance (Part 1) to better understand HTTP design, including its protocol and the processing at the server (Part 1). In Part 2, we will extend part 1 to give you a chance to become more familiar with concurrent network programming, covering topics including threads, synchronization, wait/notify (monitor), and benchmarking. Hence, when designing Part 1, please consider extension to Part 2 in mind.
The server that we will design is a simplified version of HTTP 1.0. The most basic application message, encoded in ASCII, from the client to the server is:
GET <URL> HTTP/1.0 Host: <ServerName> CRLF
where CRLF is carriage return and line feed, representing an empty line. This request asks for the file stored at location <DocRootServerName>/<URL>, where DocRootServerName is the root directory for the requested server name.
For example, if <DocRooServerNamet>=/tmp/mydoc, and <URL> is /file1.html, the server will return the file /tmp/mydoc/file1.html, if it exists. If the request does not specify the Host header, the server returns the first server (virtual host) configured; see below.
The basic reply message from the server to the client, encoded in ASCII, is:
HTTP/1.0 <StatusCode> <message> Date: <date> Server: <your server name> Content-Type: text/html Content-Length: <LengthOfFile> CRLF <file content>
CRLF again represents an empty line. If the file is found and readable, the returned <status code> is 200 and you can give a message such as OK. Otherwise, please give an error code of 400. If you are curious about HTTP error codes, you can see http://www.ietf.org/rfc/rfc1945.txt. You can use Java File class to obtain file size.
As we covered in class, a key approach to controlling the overhead of threads is to use a thread pool. We covered two designs: (1) shared welcome socket; and (2) a shared queue with wait and notify. Please implement the following two threadpool servers using a shared queue with wait and notify:
thread pool with a shared queue and busy wait;
thread pool with a shared queue and suspension;
ThreadPoolSize <number of threads>