pgbackrest.git / summary / log / commit / refs
commit 2a4137ed2eeaa769508301056226d6f86a67fd06
Author: David Steele <david@pgmasters.net>
Date: Mon Sep 26 00:15:23 2022 +0000
Add zero-length chunked content test to common/ioHttp unit.
It seems wasteful to chunk content when there is nothing to send but make sure we handle it gracefully just in case a server decides to do it.
test/src/module/common/ioHttpTest.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/test/src/module/common/ioHttpTest.c b/test/src/module/common/ioHttpTest.c
index 7b0341ae2..5b0b01701 100644
--- a/test/src/module/common/ioHttpTest.c
+++ b/test/src/module/common/ioHttpTest.c
@@ -769,6 +769,24 @@ testRun(void)
TEST_RESULT_VOID(ioRead(httpResponseIoRead(response), buffer), "read response");
TEST_RESULT_STR_Z(strNewBuf(buffer), "01234567890123456789012345678901012", "check response");
+ // -----------------------------------------------------------------------------------------------------------------
+ TEST_TITLE("request with zero-length chunked content");
+
+ hrnServerScriptExpectZ(http, "GET / HTTP/1.1\r\n" TEST_USER_AGENT "\r\n");
+ hrnServerScriptReplyZ(
+ http,
+ "HTTP/1.1 200 OK\r\nTransfer-Encoding:chunked\r\n\r\n"
+ "0\r\n\r\n");
+
+ TEST_ASSIGN(response, httpRequestResponse(httpRequestNewP(client, STRDEF("GET"), STRDEF("/")), false), "request");
+ TEST_RESULT_STR_Z(
+ httpHeaderToLog(httpResponseHeader(response)), "{transfer-encoding: 'chunked'}", "check response headers");
+
+ buffer = bufNew(0);
+
+ TEST_RESULT_VOID(ioRead(httpResponseIoRead(response), buffer), "read response");
+ TEST_RESULT_STR_Z(strNewBuf(buffer), "", "check response");
+
// -----------------------------------------------------------------------------------------------------------------
TEST_TITLE("close connection and end server process");
[parent: 64b64b614c82]