c++chilkat

Chilkat CkHttpResponse statusLine() Method is Buggy


Assume the following HTTP response with the HTTP Status Line Reason phrase ending with a space (There's a white space \x20 character after the "OK" reason phrase):

HTTP/1.1 200 OK 
Server: Microsoft-IIS/10.0
Date: Sun, 29 Feb 2010 15:14:06 GMT
Content-Length: 0

Querying a server with such a response using the following Chilkat code snippet,

// other stuff
CkHttpResponse* resp;
// other stuff
std::cout << resp->statusLine();

yields this result:

HTTP/1.1 200 OK 
Server: Microsoft-IIS/10.0

The response header parser is taking the first header after the Status Line as part of the status line string!

I couldn't find any reference to this behaviour in the RFC.

Note: I've tested it with the latest version, v9.5.0.97.

@chilkat-software


Solution

  • RFC 7230:

    status-line = HTTP-version SP status-code SP reason-phrase CRLF
    reason-phrase  = *( HTAB / SP / VCHAR / obs-text )
    

    The status line HTTP/1.1 200 OK \r\n is valid if you ensure it ends with \r\n (we can't see it in the question). In this case, Chilkat CkHttpResponse seems to be buggy.

    If otherwise the status line is HTTP/1.1 200 OK \n, then the server software is buggy.