Mercurial > hg > orthanc-wsi
comparison Resources/Orthanc/Stone/OrthancHttpConnection.cpp @ 320:196d0e18afa0
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 16 Oct 2024 14:58:02 +0200 |
parents | 0683312e21ba |
children |
comparison
equal
deleted
inserted
replaced
319:9ce06c06c984 | 320:196d0e18afa0 |
---|---|
1 /** | 1 /** |
2 * Stone of Orthanc | 2 * Stone of Orthanc |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4 * Department, University Hospital of Liege, Belgium | 4 * Department, University Hospital of Liege, Belgium |
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium | 5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium | |
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | 6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
8 * | 7 * |
9 * This program is free software: you can redistribute it and/or | 8 * This program is free software: you can redistribute it and/or |
10 * modify it under the terms of the GNU Lesser General Public License | 9 * modify it under the terms of the GNU Lesser General Public License |
11 * as published by the Free Software Foundation, either version 3 of | 10 * as published by the Free Software Foundation, either version 3 of |
21 * <http://www.gnu.org/licenses/>. | 20 * <http://www.gnu.org/licenses/>. |
22 **/ | 21 **/ |
23 | 22 |
24 | 23 |
25 #include "OrthancHttpConnection.h" | 24 #include "OrthancHttpConnection.h" |
25 | |
26 #include "../StoneToolbox.h" | |
26 | 27 |
27 namespace OrthancStone | 28 namespace OrthancStone |
28 { | 29 { |
29 void OrthancHttpConnection::Setup() | 30 void OrthancHttpConnection::Setup() |
30 { | 31 { |
53 const std::string& uri) | 54 const std::string& uri) |
54 { | 55 { |
55 boost::mutex::scoped_lock lock(mutex_); | 56 boost::mutex::scoped_lock lock(mutex_); |
56 | 57 |
57 client_.SetMethod(Orthanc::HttpMethod_Get); | 58 client_.SetMethod(Orthanc::HttpMethod_Get); |
58 client_.SetUrl(url_ + uri); | 59 client_.SetUrl(StoneToolbox::JoinUrl(url_, uri)); |
59 client_.ApplyAndThrowException(result); | 60 client_.ApplyAndThrowException(result); |
60 } | 61 } |
61 | 62 |
62 | 63 |
63 void OrthancHttpConnection::RestApiPost(std::string& result, | 64 void OrthancHttpConnection::RestApiPost(std::string& result, |
65 const std::string& body) | 66 const std::string& body) |
66 { | 67 { |
67 boost::mutex::scoped_lock lock(mutex_); | 68 boost::mutex::scoped_lock lock(mutex_); |
68 | 69 |
69 client_.SetMethod(Orthanc::HttpMethod_Post); | 70 client_.SetMethod(Orthanc::HttpMethod_Post); |
70 client_.SetUrl(url_ + uri); | 71 client_.SetUrl(StoneToolbox::JoinUrl(url_, uri)); |
71 | 72 |
72 #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) |
73 client_.SetExternalBody(body); | 74 client_.SetExternalBody(body); |
74 client_.ApplyAndThrowException(result); | 75 client_.ApplyAndThrowException(result); |
75 client_.ClearBody(); | 76 client_.ClearBody(); |
85 const std::string& body) | 86 const std::string& body) |
86 { | 87 { |
87 boost::mutex::scoped_lock lock(mutex_); | 88 boost::mutex::scoped_lock lock(mutex_); |
88 | 89 |
89 client_.SetMethod(Orthanc::HttpMethod_Put); | 90 client_.SetMethod(Orthanc::HttpMethod_Put); |
90 client_.SetUrl(url_ + uri); | 91 client_.SetUrl(StoneToolbox::JoinUrl(url_, uri)); |
91 | 92 |
92 #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) |
93 client_.SetExternalBody(body); | 94 client_.SetExternalBody(body); |
94 client_.ApplyAndThrowException(result); | 95 client_.ApplyAndThrowException(result); |
95 client_.ClearBody(); | 96 client_.ClearBody(); |
105 boost::mutex::scoped_lock lock(mutex_); | 106 boost::mutex::scoped_lock lock(mutex_); |
106 | 107 |
107 std::string result; | 108 std::string result; |
108 | 109 |
109 client_.SetMethod(Orthanc::HttpMethod_Delete); | 110 client_.SetMethod(Orthanc::HttpMethod_Delete); |
110 client_.SetUrl(url_ + uri); | 111 client_.SetUrl(StoneToolbox::JoinUrl(url_, uri)); |
111 client_.ApplyAndThrowException(result); | 112 client_.ApplyAndThrowException(result); |
112 } | 113 } |
113 } | 114 } |