Question

Can anyone guide me in acquiring the POST content-length of a website by just using sockets. Thanks and Kudos! (I'm avoiding using httpwebrequest for some reason)

Was it helpful?

Solution

If it's a proxy application you don't need to be parsing headers at all. You just need to mirror the data from one side to the other, as bytes. The only thing you need to parse is for example the initial HTTP CONNECTION request, or whatever your initial handshake with the client is that causes you to set up the upstream connection. The rest of it is just byte copying and EOS and error propagation.

OTHER TIPS

In the Http protocol the header is seperated from the content by a double crlf.

So you could either parse the header and get the Content-Length header or you can figure out the length of the content (since you know where the header ends and content starts).

HTTP/1.1 message length rules are described in section 4.4 of the RFC 2616.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top