How to write a http1.0 proxy server in c in linux?
I must develop proxy server that work with o开发者_StackOverflow社区nly HTTP 1.0 in Linux and by c . I need some hint to start developing .
- I assume you are confident in using linux and the language c (no hints for that, else don't start with developing a proxy)
- Read and understand the RFC 1945 HTTP/1.0 (pay attention to the specific mentioning of proxy)
- Determine what kind of proxy you want (web/caching/content-filter/anonymizer/transparent/non-transparent/reverse/gateway/tunnel/...)
- Start developing the server
Basic steps
- Open port
- Listen on port
- Get all request sent from the client to that port (maybe make the whole thing multithreaded to be able to handle more than 1 request at a time)
- Determine if it is a valid HTTP 1.0 request
- Extract the request components
- Rebuild the request according to what type of proxy you are
- Send the new request
- Get the response
- Send response to client
How to create a proxy server:
- Open a port to listen on
- Catch all incoming requests on that report
- Determine the web address requested
- Open a connection to the host and forward the request
- Receive response
- Send the response back to the requesting client
Additionally: Use threads to allow for multiple requests to the server.
精彩评论