Mercurial > hg > orthanc-object-storage
changeset 240:1205e4bda548
S3: rewrote the read() function
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Mon, 27 Apr 2026 19:01:47 +0200 |
| parents | 5e2e2c8d7969 |
| children | 9fd2419b17b3 |
| files | Aws/AwsS3StoragePlugin.cpp NEWS |
| diffstat | 2 files changed, 13 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/Aws/AwsS3StoragePlugin.cpp Tue Apr 14 11:02:01 2026 +0200 +++ b/Aws/AwsS3StoragePlugin.cpp Mon Apr 27 19:01:47 2026 +0200 @@ -284,28 +284,17 @@ std::string range = std::string("bytes=") + boost::lexical_cast<std::string>(fromOffset) + "-" + boost::lexical_cast<std::string>(fromOffset + size -1); getObjectRequest.SetRange(range.c_str()); } - - getObjectRequest.SetResponseStreamFactory( - [data, size]() - { - std::unique_ptr<Aws::StringStream> - istream(Aws::New<Aws::StringStream>(ALLOCATION_TAG)); - - istream->rdbuf()->pubsetbuf(static_cast<char*>(data), - size); - - return istream.release(); - }); - // Get the object auto result = client_->GetObject(getObjectRequest); - if (result.IsSuccess()) - { - } - else + if (!result.IsSuccess()) { throw StoragePluginException(std::string("error while reading file ") + path + ": response code = " + boost::lexical_cast<std::string>((int)result.GetError().GetResponseCode()) + " " + result.GetError().GetExceptionName().c_str() + " " + result.GetError().GetMessage().c_str()); } + + auto& body = result.GetResult().GetBody(); + body.read(data, size); + // it seems important to consume the HTTP stream so the connection can go back in the pool (but, it is actually already consumed !) + body.ignore(std::numeric_limits<std::streamsize>::max()); } };
--- a/NEWS Tue Apr 14 11:02:01 2026 +0200 +++ b/NEWS Mon Apr 27 19:01:47 2026 +0200 @@ -1,3 +1,10 @@ +Pending changes in the mainline +=============================== + +* AWS plugin: + * Internals: rewrote the read() function to make sure to consume the HTTP stream completely + so it can go back to the pool (although it seems to do so already) + 2026-04-13 - v 2.5.2 ====================
