0

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)

John
  • 5
  • 2
  • Could you me more specific? Are you making the request (i.e. your app is a web client) or receiving the request (i.e. your app is a HTTP server) – Justin Dec 08 '10 at 03:37
  • sorry for that, its a proxy application by the way. Both :) – John Dec 08 '10 at 03:41

3 Answers3

2

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.

user207421
  • 305,947
  • 44
  • 307
  • 483
0

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).

Shiv Kumar
  • 9,599
  • 2
  • 36
  • 38
0

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

Community
  • 1
  • 1
Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171