comparison Core/RestApi/RestApiPutCall.h @ 1446:8dc80ba768aa

refactoring: IHttpHandler does not use std::string to hold the request body
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 01 Jul 2015 13:16:12 +0200
parents f3672356c121
children 3232f1c995a5
comparison
equal deleted inserted replaced
1445:d26c8a93d05a 1446:8dc80ba768aa
37 namespace Orthanc 37 namespace Orthanc
38 { 38 {
39 class RestApiPutCall : public RestApiCall 39 class RestApiPutCall : public RestApiCall
40 { 40 {
41 private: 41 private:
42 const std::string& data_; 42 const char* bodyData_;
43 size_t bodySize_;
43 44
44 public: 45 public:
45 typedef void (*Handler) (RestApiPutCall& call); 46 typedef void (*Handler) (RestApiPutCall& call);
46 47
47 RestApiPutCall(RestApiOutput& output, 48 RestApiPutCall(RestApiOutput& output,
48 RestApi& context, 49 RestApi& context,
49 const IHttpHandler::Arguments& httpHeaders, 50 const IHttpHandler::Arguments& httpHeaders,
50 const IHttpHandler::Arguments& uriComponents, 51 const IHttpHandler::Arguments& uriComponents,
51 const UriComponents& trailing, 52 const UriComponents& trailing,
52 const UriComponents& fullUri, 53 const UriComponents& fullUri,
53 const std::string& data) : 54 const char* bodyData,
55 size_t bodySize) :
54 RestApiCall(output, context, httpHeaders, uriComponents, trailing, fullUri), 56 RestApiCall(output, context, httpHeaders, uriComponents, trailing, fullUri),
55 data_(data) 57 bodyData_(bodyData),
58 bodySize_(bodySize)
56 { 59 {
57 } 60 }
58 61
59 const std::string& GetPutBody() const 62 const char* GetBodyData() const
60 { 63 {
61 return data_; 64 return bodyData_;
65 }
66
67 size_t GetBodySize() const
68 {
69 return bodySize_;
70 }
71
72 void BodyToString(std::string& result) const
73 {
74 result.assign(bodyData_, bodySize_);
62 } 75 }
63 76
64 virtual bool ParseJsonRequest(Json::Value& result) const 77 virtual bool ParseJsonRequest(Json::Value& result) const
65 { 78 {
66 return ParseJsonRequestInternal(result, GetPutBody().c_str()); 79 return ParseJsonRequestInternal(result, bodyData_);
67 } 80 }
68 }; 81 };
69 } 82 }