diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 4614bf6c1..5534a347a 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -41,6 +41,14 @@

The expire command now checks if a stop file is present.

+ + + + + +

Handle missing reason phrase in HTTP response.

+
+ @@ -8149,6 +8157,11 @@ cjames53 + + Tenuun + ctenuun + + Cynthia Shang cmwshang diff --git a/src/common/io/http/client.c b/src/common/io/http/client.c index 33793d037..bbfaad8f6 100644 --- a/src/common/io/http/client.c +++ b/src/common/io/http/client.c @@ -320,13 +320,13 @@ httpClientRequest( ioWriteFlush(tlsSessionIoWrite(this->tlsSession)); // Read status and make sure it starts with the correct http version - String *status = strTrim(ioReadLine(tlsSessionIoRead(this->tlsSession))); + String *status = ioReadLine(tlsSessionIoRead(this->tlsSession)); if (!strBeginsWith(status, HTTP_VERSION_STR)) - THROW_FMT(FormatError, "http version of response '%s' must be " HTTP_VERSION, strPtr(status)); + THROW_FMT(FormatError, "http version of response '%s' must be " HTTP_VERSION, strPtr(strTrim(status))); - // Now read the response code and message - status = strSub(status, sizeof(HTTP_VERSION)); + // Now read the response code and message (and strip the trailing CR) + status = strSubN(status, sizeof(HTTP_VERSION), strSize(status) - sizeof(HTTP_VERSION) - 1); int spacePos = strChr(status, ' '); diff --git a/test/src/module/common/ioHttpTest.c b/test/src/module/common/ioHttpTest.c index 27f875956..ebdc56f87 100644 --- a/test/src/module/common/ioHttpTest.c +++ b/test/src/module/common/ioHttpTest.c @@ -230,7 +230,7 @@ testHttpServer(void) "\r\n"); harnessTlsServerReply( - "HTTP/1.1 403 Auth Error\r\n" + "HTTP/1.1 403 \r\n" "content-length:7\r\n" "\r\n" "CONTENT"); @@ -576,7 +576,7 @@ testRun(void) buffer, httpClientRequest(client, strNew("GET"), strNew("/"), NULL, NULL, NULL, false), "error with content length"); TEST_RESULT_UINT(httpClientResponseCode(client), 403, " check response code"); - TEST_RESULT_STR_Z(httpClientResponseMessage(client), "Auth Error", " check response message"); + TEST_RESULT_STR_Z(httpClientResponseMessage(client), "", " check empty response message"); TEST_RESULT_STR_Z( httpHeaderToLog(httpClientResponseHeader(client)), "{content-length: '7'}", " check response headers"); TEST_RESULT_STR_Z(strNewBuf(buffer), "CONTENT", " check response");