Reputation: 1
I am writing an https client to fetch https raw data using Wolfssl and http-parser. It works on regular HTML pages but not MIME type files.
The problem is that http-parser cannot decide the ending of the HTTP response stream. Based on my reading of the documents of http-parser and http protocol, I know that there are three signals related to the ending of a stream: content-length and '\r\n' after the response body and EOF. However, I found that many HTTP responses which contain a jpeg image don't contain them. For example, the response of this URL has no content-length and no '\r\n' and no EOF. https://raw.githubusercontent.com/wolfSSL/wolfssl-examples/master/SGX_Linux/README-images/expected-make-output.png
I wondered if there are other ways to find the ending of the stream or if there are some bugs in my code?
Upvotes: 0
Views: 119
Reputation: 1
I have found a bug in my code.
After reading some data from the socket, I used strlen() of the recv_buf as the lengh of the receiving data. This may be right when reading data from regular HTTP pages but will fail when reading an image file.
So I guess http-parser can correctly find the ending of a response stream.
Upvotes: 0