Phone:

+(886) 909 756 966

Email:
moneychien20639@gmail.com

© 2024 Yu-Hang

Course:

Introduction to Computer Systems (15-513)

Time Spent:

30 hours

Source Code:
to github

Proxy Lab

This program implements a simple HTTP proxy server. It accepts client requests, forwards them to the appropriate web servers, and returns the responses to the clients. The proxy handles GET requests and rewrites the headers to include required fields like User-Agent.

Key Design Decisions:
- Multi-threaded Handling: Each client request is handled by a separate thread, ensuring concurrent processing. Threads are detached to automatically clean up resources after completion.

Request Parsing:
Utilized a custom HTTP parser to extract important fields from HTTP requests. Parsed method, host, path, and port from the client's request.

Header Management:
Constructed HTTP request headers including User-Agent, Connection, and Proxy-Connection. Ensured the Host header is always sent, either copied from the client or constructed as needed.

Forwarding Requests:
Established a connection to the target web server, forwarded the client's request, and returned the server's response to the client. Managed both request and response headers efficiently.

Error Handling:
Implemented robust error handling to return appropriate HTTP error messages (e.g., 400 Bad Request, 501 Not Implemented). Ensured the proxy server continues running smoothly in the face of various errors.

Implementation Details:
- Used POSIX threads to handle multiple client connections concurrently.
- Adopted the CSAPP robust I/O package for reliable socket communication.
- Employed the provided HTTP parsing library for efficient request parsing and header management.
- Integrated thorough testing using the PxyDrive and PxyRegress frameworks provided in the lab handout.


  • C
  • HTTP Proxy Server
  • Multi-threaded Programming
  • Network Programming
  • POSIX Threads
  • Socket Programming
  • Concurrent Processing
  • Error Handling