0% found this document useful (0 votes)
14 views4 pages

CSE 310 Web Server and Proxy Assignment

The document outlines a programming assignment for CSE 310 Spring 2025, divided into two parts: creating a web server and a web proxy server. Part A focuses on socket programming to develop a web server that handles HTTP requests and responses, including error handling for missing files. Part B requires the development of a web proxy server that caches web pages and handles GET requests, with specific submission guidelines for code and documentation.

Uploaded by

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

CSE 310 Web Server and Proxy Assignment

The document outlines a programming assignment for CSE 310 Spring 2025, divided into two parts: creating a web server and a web proxy server. Part A focuses on socket programming to develop a web server that handles HTTP requests and responses, including error handling for missing files. Part B requires the development of a web proxy server that caches web pages and handles GET requests, with specific submission guidelines for code and documentation.

Uploaded by

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

Programming Assignment 1

CSE 310 Spring 2025


Due date: March 4, 2025; 5:00 PM
Submission via Brightspace

Part A. (50 points) Web Server

In this part of the assignment, you will learn the basics of socket programming for TCP
connections in Python: how to create a socket, bind it to a specific address and port, as well as
send and receive a HTTP packet. You will also learn some basics of HTTP header format.

Develop a web server that handles one HTTP request at a time. Your web server should be able
to (a) accept and parse the HTTP request, get the requested file from the server’s file system, (b)
create an HTTP response message consisting of the requested file preceded by the status and
header lines, and then (c) send the response directly to the client. (d) If the requested file is not
present in the server, the server should send an HTTP “404 Not Found” message back to the
client.

Running the Server

Put an HTML file (e.g., [Link]) in the same directory that the server is in. Run the server
program. Determine the IP address of the host that is running the server (e.g., [Link]).
You can also use localhost if the server is running on the same host. From another (or the same)
host, open a browser and provide the corresponding URL. For example:
[Link]

‘[Link]’ is the name of the file you placed in the server directory. Note also the use of
the port number after the colon. You need to replace this port number with whatever port you
have used in the server code. In the above example, we have used the port number 6789. The
browser should then display the contents of [Link]. If you omit ":6789", the browser
will assume port 80 and you will get the web page from the server only if your server is listening
at port 80. Your server should be able to handle any request for .html, .jpeg, .png, .txt if they are
in your server directory.

Then try to get a file that is not present at the server. You should get a “404 Not Found” message.
You're not allowed to use a separate Html file for 404. It must be part of the HTTP response
message.

Client should be able to request text as well as image (jpeg, png, etc) files from the server.

What to submit
Please submit the complete server code ([Link]) along with the screen shots of your client
browser, verifying that you actually receive the contents of the HTML file from the server.

Part B. (50 points) Web Proxy

In this part of the assignment, you will learn how web proxy servers work and one of their basic
functionalities – caching.

Your task is to develop a small web proxy server which is able to cache web pages. It is a very
simple proxy server which only understands simple GET requests, but is able to handle all kinds
of objects - not just HTML pages, but also images.

Generally, when the client makes a request, the request is sent to the web server. The web server
then processes the request and sends back a response message to the requesting client. In order
to improve the performance, we create a proxy server between the client and the web server.
Now, both the request message sent by the client and the response message delivered by the
web server pass through the proxy server. In other words, the client requests the objects via the
proxy server. The proxy server will forward the client’s request to the web server. The web server
will then generate a response message and deliver it to the proxy server, which in turn sends it
to the client.

Running the Proxy Server

Run the proxy server program using your command prompt and then request a web page from
your browser. Direct the requests to the proxy server using your IP address and port number.

For e.g. [Link]

To use the proxy server with browser and proxy on separate computers, you will need the IP
address on which your proxy server is running. In this case, while running the proxy, you will have
to replace the “localhost” with the IP address of the computer where the proxy server is running.
Also note the port number used. You will replace the port number used here “8888” with the
port number you have used in your server code at which your proxy server is listening.

Configuring your Browser

You can also directly configure your web browser to use your proxy. This depends on your
browser. For example, in Internet Explorer, you can set the proxy in Tools > Internet Options >
Connections tab > LAN Settings. You need to give the address of the proxy and the port number
that you gave when you ran the proxy server. You should be able to run the proxy and the
browser on the same computer without any problem. With this approach, to get a web page
using the proxy server, you simply provide the URL of the page you want.

For e.g. [Link]

What to submit

Please submit the complete proxy server code ([Link]) and screenshots at the client side
verifying that you indeed get the web page via the proxy server. Try different browsers if
something doesn’t work.

***********************************************************

Submission Guidelines

You need to submit your homework in a single zip file as follows:

• The zip file and (the root folder inside) should be named using your last name, first name,
and the assignment number, all separated by a dash (‘-‘)
e.g. [Link]
• The zip file should contain your code corresponding to Part A and Part B. Please be sure
to put code in the root folder rather than in separate folders. Provide sufficient comments
in your code.
• Include the screenshots for Part A and Part B in a single PDF file, and name it
‘clients_screenshots’.
• Directory structure you can follow:
Files inside ‘lastname-firstname-assignment1’:
• [Link]
• [Link]
• clients_screenshots.pdf
• .html file for part A
• README
• Flask and SimpleHTTPServer are NOT allowed. Please use socket programming only. You
can use the server code discussed in class as a starting point.
• You cannot use [Link] library to parse URLs
• You can handle only HTTP requests. No need to handle HTTPS requests. Some websites
will only support HTTPS. You may need to find one that uses HTTP.
• You can try the following test webpages, they should work with http1.0.
• [Link]
• [Link]
• [Link]
• [Link]
• You should provide a README file describing:
• Any external libraries used.
• Instructions on how to run your programs.
• Webpages that your code successfully works for.

Common questions

Powered by AI

Testing the proxy server with multiple browsers ensures that the proxy implementation correctly handles diverse HTTP request formats and headers typical of different browsers. This promotes robust design capable of interfacing with various client software and avoiding reliance on browser-specific features, thereby ensuring broader compatibility and reliability .

Limiting the assignment to handle only HTTP requests might pose challenges, such as difficulty accessing some modern websites that default to HTTPS. This could limit the testing range of the server and proxy implementations. Additionally, students might miss learning opportunities about securing communication over the internet, as HTTPS adds layers of complexity and security through SSL/TLS protocols .

Restricting the use of Flask and SimpleHTTPServer ensures that students gain a deeper understanding of socket programming by requiring them to implement low-level networking functionalities themselves. This enhances practical knowledge of creating sockets, binding them to specific addresses, managing HTTP requests and responses, and controlling socket-level I/O operations without relying on higher-level libraries that abstract these details .

Avoiding 'urllib.parse' for URL parsing drives students to programmatically dissect and understand URL components, enhancing their operational understanding of URL structures and the HTTP protocol. This constraint encourages them to develop algorithms for parsing, thus fostering problem-solving skills and a deeper technical comprehension of network communications .

To confirm that the web server can handle various file types correctly, students should place different file types such as `.html`, `.jpeg`, `.png`, and `.txt` in the server directory and ensure the server can serve these files upon request. Additionally, attempts to request files not present in the directory should result in receiving a '404 Not Found' message, verifying error handling .

The assignment instructs students to implement functionality in the web server to handle requests for files not present by sending a '404 Not Found' HTTP response message back to the client. This response should be part of the HTTP message rather than served from a separate HTML file .

Caching can improve the performance of a web proxy server by temporarily storing copies of frequently requested web pages and objects. When a client requests one of these cached objects, the proxy server can deliver the object directly from its cache without having to forward the request to the web server, thus reducing latency and server load .

Creating a web proxy server deepens understanding of network communications as it requires handling both client and server interactions. Students learn about request routing, response transformation, and caching mechanisms. A proxy must efficiently manage dual communications streams, often involving additional functionalities like filtering and logging. This complexity contrasts with a web server, which focuses on responding to client requests .

The critical components of the web server's HTTP response include the status line and header lines, followed by the requested file's content. The response should convey the HTTP status code (such as '200 OK' or '404 Not Found') and necessary header information before delivering the requested file to the client .

Specifying a directory structure for assignment submission ensures consistency in file organization, making it easier for instructors to locate and evaluate the necessary components, such as code and screenshots. It streamlines the grading process, facilitates automated testing if implemented, and reduces errors or confusion arising from ambiguous file arrangements .

You might also like