Glitch with MessageHeader

Please post support and help requests here.
merdem
Posts: 14
Joined: 19 Jul 2006, 22:28

Glitch with MessageHeader

Postby merdem » 19 Oct 2006, 22:27

Hello,

While I was working with HTTPClientSession, I realized that the MessageHeader::read might sometimes parse the HTTP header in an incorrect way.

The HTTP server response I had the problem with is:

[snip]

HTTP/1.1 200 OK
Date: Thu, 19 Oct 2006 16:17:40 GMT
Accept-Ranges: bytes
Connection: close
HTTP/1.0 200 OK
Content-Type: text/plain

[/snip]

which is produced by an IP camera. Note the extra "HTTP/1.0 200 OK" line. I don't know if this spurious line is legal, but MessageHeader::read(...) fails to parse correctly the following Content-Type field. It is not expecting a newline character in the middle of the name field.

A simple fix is to add the marked line:

...
std::string name;
std::string value;
while (ch != eof && ch != ':' && name.length() < MAX_NAME_LENGTH && ch != '
') { name += ch; ch = istr.get(); }
if (ch == '
') {ch = istr.get(); continue;} <<<<<<<<< ADD THIS LINE
if (ch != ':') throw MessageException("Field name too long/no colon found");
...

in the messageheader.cpp file, MessageHeader::read(std::istream& istr) body. With this modification, any line with no ':' separator will be ignored.

Hope this helps.

Murat

guenter
Posts: 1183
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Glitch with MessageHeader

Postby guenter » 20 Oct 2006, 09:05

> HTTP/1.1 200 OK
> Date: Thu, 19 Oct 2006 16:17:40 GMT
> Accept-Ranges: bytes
> Connection: close
> HTTP/1.0 200 OK
> Content-Type: text/plain

That's definitely not a valid HTTP header.
What camera are you working with?

Anyway, I will incorporate the fix into the next release. After all, the old saying goes "be strict in what you emit, and liberal in what you accept"...


Return to “Support”

Who is online

Users browsing this forum: No registered users and 3 guests