How to write a http1.0 proxy server in c in linux?

2020-06-23 06:02发布

I must develop proxy server that work with only HTTP 1.0 in Linux and by c . I need some hint to start developing .

2条回答
Root(大扎)
2楼-- · 2020-06-23 06:22
  • 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

  1. Open port
  2. Listen on port
  3. 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)
  4. Determine if it is a valid HTTP 1.0 request
  5. Extract the request components
  6. Rebuild the request according to what type of proxy you are
  7. Send the new request
  8. Get the response
  9. Send response to client
查看更多
\"骚年 ilove
3楼-- · 2020-06-23 06:36

How to create a proxy server:

  1. Open a port to listen on
  2. Catch all incoming requests on that report
  3. Determine the web address requested
  4. Open a connection to the host and forward the request
  5. Receive response
  6. Send the response back to the requesting client

Additionally: Use threads to allow for multiple requests to the server.

查看更多
登录 后发表回答