1

I am implementing HTTP server which will be responsible for:
1. Receiving requests from a browser and forwarding it to another HTTP sever. 2. And reading response from HTTP server and forwarding it directly to the browser.

In this case i am taking care of modifying only host name in the received request while sending it to HTTP server over the socket using send() socket API, I am using socket connection with HTTP server to forward the HTTP request received from browser.

I have following queries:

  1. Will HTTP request forwarding work with recv() and send() socket APIs.
  2. If recv() returns 0 then either server or browser has closed the socket?
    But some times my application gets stuck in receive and does not return for 1-2 mins.
  3. For receiving data on socket from the server do i need to wait till recv() returns 0 or do i need to check content length of the received data and then continue with recv().

I am very new to HTTP. If any one has sample application for forwarding http requests then please provide, so that i can learn it better.

User7723337
  • 11,857
  • 27
  • 101
  • 182
Sudarshan
  • 11
  • 1
  • 1
    You're implementing sort of a http proxy, so you can look at the source of any http proxy. [sourceforge](http://sourceforge.net/directory/?q=http+proxy) could be a start. – Olaf Dietsche Oct 22 '12 at 13:01
  • hmm... I wonder why you are trying to set up "man in the middle" software – thecoshman Oct 22 '12 at 13:08
  • You want to implement the entire HTTP protocol? Probably not a good idea given that you are *"very new to HTTP"*. –  Oct 23 '12 at 14:27

0 Answers0