Mercurial > hg > orthanc-transfers
comparison Framework/HttpQueries/HttpQueriesQueue.cpp @ 44:f4e828607f02
Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 19 Oct 2022 21:12:57 +0200 |
parents | 44a0430d7899 |
children | 1e396fb509ca |
comparison
equal
deleted
inserted
replaced
43:c3fefbb11321 | 44:f4e828607f02 |
---|---|
133 if (query->GetMethod() == Orthanc::HttpMethod_Post || | 133 if (query->GetMethod() == Orthanc::HttpMethod_Post || |
134 query->GetMethod() == Orthanc::HttpMethod_Put) | 134 query->GetMethod() == Orthanc::HttpMethod_Put) |
135 { | 135 { |
136 query->ReadBody(body); | 136 query->ReadBody(body); |
137 } | 137 } |
138 | |
139 std::map<std::string, std::string> headers; | |
140 query->GetHttpHeaders(headers); | |
138 | 141 |
139 unsigned int retry = 0; | 142 unsigned int retry = 0; |
140 | 143 |
141 for (;;) | 144 for (;;) |
142 { | 145 { |
147 try | 150 try |
148 { | 151 { |
149 switch (query->GetMethod()) | 152 switch (query->GetMethod()) |
150 { | 153 { |
151 case Orthanc::HttpMethod_Get: | 154 case Orthanc::HttpMethod_Get: |
152 success = peers_.DoGet(answer, query->GetPeer(), query->GetUri()); | 155 success = peers_.DoGet(answer, query->GetPeer(), query->GetUri(), headers); |
153 break; | 156 break; |
154 | 157 |
155 case Orthanc::HttpMethod_Post: | 158 case Orthanc::HttpMethod_Post: |
156 success = peers_.DoPost(answer, query->GetPeer(), query->GetUri(), body); | 159 success = peers_.DoPost(answer, query->GetPeer(), query->GetUri(), body, headers); |
157 break; | 160 break; |
158 | 161 |
159 case Orthanc::HttpMethod_Put: | 162 case Orthanc::HttpMethod_Put: |
160 success = peers_.DoPut(query->GetPeer(), query->GetUri(), body); | 163 success = peers_.DoPut(query->GetPeer(), query->GetUri(), body, headers); |
161 break; | 164 break; |
162 | 165 |
163 case Orthanc::HttpMethod_Delete: | 166 case Orthanc::HttpMethod_Delete: |
164 success = peers_.DoDelete(query->GetPeer(), query->GetUri()); | 167 success = peers_.DoDelete(query->GetPeer(), query->GetUri(), headers); |
165 break; | 168 break; |
166 | 169 |
167 default: | 170 default: |
168 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 171 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
169 } | 172 } |
170 } | 173 } |
171 catch (Orthanc::OrthancException& e) | 174 catch (Orthanc::OrthancException& e) |
172 { | 175 { |
173 LOG(ERROR) << "Unhandled exception during an HTTP query to peer \"" | 176 LOG(ERROR) << "Unhandled exception during an HTTP query to peer \"" |
174 << query->GetPeer() << "\": " << e.What(); | 177 << query->GetPeer() << " " << query->GetUri() + "\": " << e.What(); |
175 success = false; | 178 success = false; |
176 } | 179 } |
177 | 180 |
178 if (success) | 181 if (success) |
179 { | 182 { |
219 // Wait 1 second before retrying | 222 // Wait 1 second before retrying |
220 boost::this_thread::sleep(boost::posix_time::seconds(1)); | 223 boost::this_thread::sleep(boost::posix_time::seconds(1)); |
221 } | 224 } |
222 else | 225 else |
223 { | 226 { |
224 LOG(INFO) << "Reached the maximum number of retries for a HTTP query"; | 227 if (maxRetries > 0) |
228 { | |
229 LOG(ERROR) << "Reached the maximum number of retries for a HTTP query to peer " << query->GetPeer() << " " << query->GetUri(); | |
230 } | |
225 | 231 |
226 { | 232 { |
227 boost::mutex::scoped_lock lock(mutex_); | 233 boost::mutex::scoped_lock lock(mutex_); |
228 isFailure_ = true; | 234 isFailure_ = true; |
229 completed_.notify_all(); | 235 completed_.notify_all(); |