Mercurial > hg > orthanc-dicomweb
changeset 548:02f8da1ac118
fix HTTP headers forwarding
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 17 Oct 2022 13:35:44 +0200 (2022-10-17) |
parents | 8f7dc9fb995a |
children | d6ed864fda66 |
files | Plugin/StowRs.cpp Plugin/StowRs.h |
diffstat | 2 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugin/StowRs.cpp Fri Oct 14 16:08:14 2022 +0200 +++ b/Plugin/StowRs.cpp Mon Oct 17 13:35:44 2022 +0200 @@ -39,7 +39,8 @@ success_(Json::arrayValue), failed_(Json::arrayValue), hasBadSyntax_(false), - hasConflict_(false) + hasConflict_(false), + headers_(headers) { std::string tmp, contentType, subType, boundary; if (!Orthanc::MultipartStreamReader::GetMainContentType(tmp, headers) || @@ -182,7 +183,19 @@ try { MemoryBuffer tmp; - ok = tmp.RestApiPost("/instances", part, size, headers, true); + + // make sure to forward the auth headers in the request that is sent to Orthanc (to allow usage of the auth plugin) + // since we do not know which header is being used, we include all the headers from the Stow-RS request (headers_), replace + // the "content-disposition" + "content-type" that are rebuilt from the multi-part message and remove the headers that might + // be mi-interpreted by Orthanc core (like "content-length" that is actually the "content-length" from the whole Stow-RS request, not the length of this file) + Orthanc::MultipartStreamReader::HttpHeaders mergedHeaders = headers_; + Orthanc::MultipartStreamReader::HttpHeaders::iterator foundContentLength = mergedHeaders.find("content-length"); + if (foundContentLength != mergedHeaders.end()) + { + mergedHeaders.erase(foundContentLength); + } + + ok = tmp.RestApiPost("/instances", part, size, mergedHeaders, true); tmp.Clear(); } catch (Orthanc::OrthancException& ex)