Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect end of Http request?

I am creating a Http request parser. I am getting data in chunks (byte array) and parsing it simultaneously. I want to know the condition of detecting end of http request. The request may or may not contain message body.

Thanks

like image 919
vijay053 Avatar asked Sep 03 '25 03:09

vijay053


1 Answers

Three different ways:

  • content-length header (number of bytes following the headers)

  • chunked encoding (content length unknown at start of request, chunked encoding will indicate when the end is reached)

  • connection closed by server (http "0.9")

like image 118
spender Avatar answered Sep 05 '25 20:09

spender