Mercurial > hg > orthanc
comparison Core/RestApi/RestApiOutput.cpp @ 1042:8d1845feb277
set cookies, not allowed methods, unauthorized in plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 17 Jul 2014 15:55:40 +0200 |
parents | a811bdf8b8eb |
children | 00f9f36bcd94 |
comparison
equal
deleted
inserted
replaced
1041:2c49b7dffcec | 1042:8d1845feb277 |
---|---|
71 void RestApiOutput::AnswerJson(const Json::Value& value) | 71 void RestApiOutput::AnswerJson(const Json::Value& value) |
72 { | 72 { |
73 CheckStatus(); | 73 CheckStatus(); |
74 Json::StyledWriter writer; | 74 Json::StyledWriter writer; |
75 std::string s = writer.write(value); | 75 std::string s = writer.write(value); |
76 output_.AnswerBufferWithContentType(s, "application/json", cookies_); | 76 output_.AnswerBufferWithContentType(s, "application/json"); |
77 alreadySent_ = true; | 77 alreadySent_ = true; |
78 } | 78 } |
79 | 79 |
80 void RestApiOutput::AnswerBuffer(const std::string& buffer, | 80 void RestApiOutput::AnswerBuffer(const std::string& buffer, |
81 const std::string& contentType) | 81 const std::string& contentType) |
82 { | 82 { |
83 CheckStatus(); | 83 CheckStatus(); |
84 output_.AnswerBufferWithContentType(buffer, contentType, cookies_); | 84 output_.AnswerBufferWithContentType(buffer, contentType); |
85 alreadySent_ = true; | 85 alreadySent_ = true; |
86 } | 86 } |
87 | 87 |
88 void RestApiOutput::AnswerBuffer(const void* buffer, | 88 void RestApiOutput::AnswerBuffer(const void* buffer, |
89 size_t length, | 89 size_t length, |
90 const std::string& contentType) | 90 const std::string& contentType) |
91 { | 91 { |
92 CheckStatus(); | 92 CheckStatus(); |
93 output_.AnswerBufferWithContentType(buffer, length, contentType, cookies_); | 93 output_.AnswerBufferWithContentType(buffer, length, contentType); |
94 alreadySent_ = true; | 94 alreadySent_ = true; |
95 } | 95 } |
96 | 96 |
97 void RestApiOutput::Redirect(const std::string& path) | 97 void RestApiOutput::Redirect(const std::string& path) |
98 { | 98 { |
133 if (maxAge != 0) | 133 if (maxAge != 0) |
134 { | 134 { |
135 v += ";max-age=" + boost::lexical_cast<std::string>(maxAge); | 135 v += ";max-age=" + boost::lexical_cast<std::string>(maxAge); |
136 } | 136 } |
137 | 137 |
138 cookies_[name] = v; | 138 output_.SetCookie(name, v); |
139 } | 139 } |
140 | 140 |
141 void RestApiOutput::ResetCookie(const std::string& name) | 141 void RestApiOutput::ResetCookie(const std::string& name) |
142 { | 142 { |
143 // This marks the cookie to be deleted by the browser in 1 second, | 143 // This marks the cookie to be deleted by the browser in 1 second, |