Mercurial > hg > orthanc
comparison OrthancFramework/Sources/Lua/LuaContext.cpp @ 4650:9804d6490872
Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 May 2021 10:57:42 +0200 |
parents | d9473bd5ed43 |
children | 7053502fbf97 |
comparison
equal
deleted
inserted
replaced
4649:e915102093de | 4650:9804d6490872 |
---|---|
237 | 237 |
238 // Configure the HTTP client class | 238 // Configure the HTTP client class |
239 const char* url = lua_tostring(state, 1); | 239 const char* url = lua_tostring(state, 1); |
240 that.httpClient_.SetMethod(HttpMethod_Get); | 240 that.httpClient_.SetMethod(HttpMethod_Get); |
241 that.httpClient_.SetUrl(url); | 241 that.httpClient_.SetUrl(url); |
242 that.httpClient_.GetBody().clear(); | 242 that.httpClient_.ClearBody(); |
243 that.SetHttpHeaders(2); | 243 that.SetHttpHeaders(2); |
244 | 244 |
245 // Do the HTTP GET request | 245 // Do the HTTP GET request |
246 if (!that.AnswerHttpQuery(state)) | 246 if (!that.AnswerHttpQuery(state)) |
247 { | 247 { |
282 size_t bodySize = 0; | 282 size_t bodySize = 0; |
283 const char* bodyData = lua_tolstring(state, 2, &bodySize); | 283 const char* bodyData = lua_tolstring(state, 2, &bodySize); |
284 | 284 |
285 if (bodySize == 0) | 285 if (bodySize == 0) |
286 { | 286 { |
287 that.httpClient_.GetBody().clear(); | 287 that.httpClient_.ClearBody(); |
288 } | 288 } |
289 else | 289 else |
290 { | 290 { |
291 that.httpClient_.GetBody().assign(bodyData, bodySize); | 291 that.httpClient_.AssignBody(bodyData, bodySize); |
292 } | 292 } |
293 } | 293 } |
294 else | 294 else |
295 { | 295 { |
296 that.httpClient_.GetBody().clear(); | 296 that.httpClient_.ClearBody(); |
297 } | 297 } |
298 | 298 |
299 // Do the HTTP POST/PUT request | 299 // Do the HTTP POST/PUT request |
300 if (!that.AnswerHttpQuery(state)) | 300 if (!that.AnswerHttpQuery(state)) |
301 { | 301 { |
340 | 340 |
341 // Configure the HTTP client class | 341 // Configure the HTTP client class |
342 const char* url = lua_tostring(state, 1); | 342 const char* url = lua_tostring(state, 1); |
343 that.httpClient_.SetMethod(HttpMethod_Delete); | 343 that.httpClient_.SetMethod(HttpMethod_Delete); |
344 that.httpClient_.SetUrl(url); | 344 that.httpClient_.SetUrl(url); |
345 that.httpClient_.GetBody().clear(); | 345 that.httpClient_.ClearBody(); |
346 that.SetHttpHeaders(2); | 346 that.SetHttpHeaders(2); |
347 | 347 |
348 // Do the HTTP DELETE request | 348 // Do the HTTP DELETE request |
349 std::string s; | 349 std::string s; |
350 if (!that.httpClient_.Apply(s)) | 350 if (!that.httpClient_.Apply(s)) |