2

Is there any rule for http server implementation to read or skip the request body before sending a response?

long
  • 414
  • 4
  • 15

1 Answers1

-1

Once you have received the full HTTP request you are free to do with it whatever you want to do with it. If you don't care about the body you can simply read it and discard it. You should empty the read buffer obviously.

Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122
  • So, I _should_ empty the read buffer, not _must _? Is there any reference to some official standard for that? – long Dec 07 '15 at 16:25
  • 1
    @long That depends on your network implementation, if you just start receiving again and the receiving function is happy to overwrite the leftover data you didn't read then you don't have to. The HTTP spec doesn't say anything about this at all though. This is just networking. – Hatted Rooster Dec 07 '15 at 16:27
  • I don't think this answers the question, which is actually "can the server start sending the response while it is still reading the request?". The need to "empty the read buffer" may be obvious, but the need to "empty the read buffer *before sending the response*" is not. – avakar Jan 28 '17 at 07:32