diff options
| author | Dan Engelbrecht <[email protected]> | 2026-03-11 16:12:00 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-03-11 16:12:00 +0100 |
| commit | 1a3a175a2ca0c06a29e6a679c325395c8008a17e (patch) | |
| tree | 21156d69bb90bc5c6f539fff02e4c23c229269a4 /src/zenhttp/httpclient_test.cpp | |
| parent | improved oplog import progress reporting (#825) (diff) | |
| download | zen-1a3a175a2ca0c06a29e6a679c325395c8008a17e.tar.xz zen-1a3a175a2ca0c06a29e6a679c325395c8008a17e.zip | |
added streaming download of payloads http client Post (#824)
* added streaming download of payloads in cpr client ::Post
* curlclient Post streaming download
* case sensitivity fixes for http headers
* move over missing functionality from crpclient to httpclient
Diffstat (limited to 'src/zenhttp/httpclient_test.cpp')
| -rw-r--r-- | src/zenhttp/httpclient_test.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/zenhttp/httpclient_test.cpp b/src/zenhttp/httpclient_test.cpp index 2d949c546..5f3ad2455 100644 --- a/src/zenhttp/httpclient_test.cpp +++ b/src/zenhttp/httpclient_test.cpp @@ -514,6 +514,50 @@ TEST_CASE("httpclient.download") } } +TEST_CASE("httpclient.post-streaming") +{ + TestServerFixture Fixture; + ScopedTemporaryDirectory PostDir; + + SUBCASE("POST CbObject with TempFolderPath stays in memory when response is small") + { + HttpClient Client = Fixture.MakeClient(); + + CbObjectWriter Writer; + Writer.AddBool("streaming", false); + Writer.AddString("mode", "memory"); + CbObject Obj = Writer.Save(); + + HttpClient::Response Resp = Client.Post("/api/test/echo", Obj, {}, PostDir.Path()); + CHECK(Resp.IsSuccess()); + IoBufferFileReference _; + CHECK(!Resp.ResponsePayload.GetFileReference(_)); + CbObject RoundTripped = Resp.AsObject(); + CHECK(RoundTripped["streaming"].AsBool() == false); + CHECK_EQ(RoundTripped["mode"].AsString(), "memory"); + } + + SUBCASE("POST CbObject with TempFolderPath streams to file when response exceeds MaximumInMemoryDownloadSize") + { + HttpClientSettings Settings; + Settings.MaximumInMemoryDownloadSize = 4; + HttpClient Client = Fixture.MakeClient(Settings); + + CbObjectWriter Writer; + Writer.AddBool("streaming", true); + Writer.AddString("mode", "file"); + CbObject Obj = Writer.Save(); + + HttpClient::Response Resp = Client.Post("/api/test/echo", Obj, {}, PostDir.Path()); + CHECK(Resp.IsSuccess()); + IoBufferFileReference _; + CHECK(Resp.ResponsePayload.GetFileReference(_)); + CbObject RoundTripped = Resp.AsObject(); + CHECK(RoundTripped["streaming"].AsBool() == true); + CHECK_EQ(RoundTripped["mode"].AsString(), "file"); + } +} + TEST_CASE("httpclient.status-codes") { TestServerFixture Fixture; |