comparison OrthancStone/Sources/Toolbox/OrthancDatasets/OrthancHttpConnection.cpp @ 2153:32bfccdc030f

consistency in the way URLs are concatenated
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Sep 2024 18:09:24 +0200
parents 16c01cc201e7
children
comparison
equal deleted inserted replaced
2151:02a06434833c 2153:32bfccdc030f
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 **/ 21 **/
22 22
23 23
24 #include "OrthancHttpConnection.h" 24 #include "OrthancHttpConnection.h"
25
26 #include "../StoneToolbox.h"
25 27
26 namespace OrthancStone 28 namespace OrthancStone
27 { 29 {
28 void OrthancHttpConnection::Setup() 30 void OrthancHttpConnection::Setup()
29 { 31 {
52 const std::string& uri) 54 const std::string& uri)
53 { 55 {
54 boost::mutex::scoped_lock lock(mutex_); 56 boost::mutex::scoped_lock lock(mutex_);
55 57
56 client_.SetMethod(Orthanc::HttpMethod_Get); 58 client_.SetMethod(Orthanc::HttpMethod_Get);
57 client_.SetUrl(url_ + uri); 59 client_.SetUrl(StoneToolbox::JoinUrl(url_, uri));
58 client_.ApplyAndThrowException(result); 60 client_.ApplyAndThrowException(result);
59 } 61 }
60 62
61 63
62 void OrthancHttpConnection::RestApiPost(std::string& result, 64 void OrthancHttpConnection::RestApiPost(std::string& result,
64 const std::string& body) 66 const std::string& body)
65 { 67 {
66 boost::mutex::scoped_lock lock(mutex_); 68 boost::mutex::scoped_lock lock(mutex_);
67 69
68 client_.SetMethod(Orthanc::HttpMethod_Post); 70 client_.SetMethod(Orthanc::HttpMethod_Post);
69 client_.SetUrl(url_ + uri); 71 client_.SetUrl(StoneToolbox::JoinUrl(url_, uri));
70 72
71 #if defined(ORTHANC_FRAMEWORK_VERSION_IS_ABOVE) && ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 9, 3) 73 #if defined(ORTHANC_FRAMEWORK_VERSION_IS_ABOVE) && ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 9, 3)
72 client_.SetExternalBody(body); 74 client_.SetExternalBody(body);
73 client_.ApplyAndThrowException(result); 75 client_.ApplyAndThrowException(result);
74 client_.ClearBody(); 76 client_.ClearBody();
84 const std::string& body) 86 const std::string& body)
85 { 87 {
86 boost::mutex::scoped_lock lock(mutex_); 88 boost::mutex::scoped_lock lock(mutex_);
87 89
88 client_.SetMethod(Orthanc::HttpMethod_Put); 90 client_.SetMethod(Orthanc::HttpMethod_Put);
89 client_.SetUrl(url_ + uri); 91 client_.SetUrl(StoneToolbox::JoinUrl(url_, uri));
90 92
91 #if defined(ORTHANC_FRAMEWORK_VERSION_IS_ABOVE) && ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 9, 3) 93 #if defined(ORTHANC_FRAMEWORK_VERSION_IS_ABOVE) && ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 9, 3)
92 client_.SetExternalBody(body); 94 client_.SetExternalBody(body);
93 client_.ApplyAndThrowException(result); 95 client_.ApplyAndThrowException(result);
94 client_.ClearBody(); 96 client_.ClearBody();
104 boost::mutex::scoped_lock lock(mutex_); 106 boost::mutex::scoped_lock lock(mutex_);
105 107
106 std::string result; 108 std::string result;
107 109
108 client_.SetMethod(Orthanc::HttpMethod_Delete); 110 client_.SetMethod(Orthanc::HttpMethod_Delete);
109 client_.SetUrl(url_ + uri); 111 client_.SetUrl(StoneToolbox::JoinUrl(url_, uri));
110 client_.ApplyAndThrowException(result); 112 client_.ApplyAndThrowException(result);
111 } 113 }
112 } 114 }