comparison Core/HttpServer/HttpOutput.cpp @ 339:639272ef7615

answer raw buffers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 Jan 2013 15:14:54 +0100
parents 78a8eaa5f30b
children bdd72233b105
comparison
equal deleted inserted replaced
338:3a3b3ba8c1e0 339:639272ef7615
139 SendOkHeader(contentType.c_str(), true, buffer.size(), NULL); 139 SendOkHeader(contentType.c_str(), true, buffer.size(), NULL);
140 SendString(buffer); 140 SendString(buffer);
141 } 141 }
142 142
143 143
144 void HttpOutput::PrepareCookies(Header& header,
145 const HttpHandler::Arguments& cookies)
146 {
147 for (HttpHandler::Arguments::const_iterator it = cookies.begin();
148 it != cookies.end(); it++)
149 {
150 header.push_back(std::make_pair("Set-Cookie", it->first + "=" + it->second));
151 }
152 }
153
154
144 void HttpOutput::AnswerBufferWithContentType(const std::string& buffer, 155 void HttpOutput::AnswerBufferWithContentType(const std::string& buffer,
145 const std::string& contentType, 156 const std::string& contentType,
146 const HttpHandler::Arguments& cookies) 157 const HttpHandler::Arguments& cookies)
147 { 158 {
148 Header header; 159 Header header;
149 PrepareOkHeader(header, contentType.c_str(), true, buffer.size(), NULL); 160 PrepareOkHeader(header, contentType.c_str(), true, buffer.size(), NULL);
150 161 PrepareCookies(header, cookies);
151 for (HttpHandler::Arguments::const_iterator it = cookies.begin();
152 it != cookies.end(); it++)
153 {
154 header.push_back(std::make_pair("Set-Cookie", it->first + "=" + it->second));
155 }
156
157 SendOkHeader(header); 162 SendOkHeader(header);
158 SendString(buffer); 163 SendString(buffer);
159 } 164 }
160 165
161 166
165 { 170 {
166 SendOkHeader(contentType.c_str(), true, size, NULL); 171 SendOkHeader(contentType.c_str(), true, size, NULL);
167 Send(buffer, size); 172 Send(buffer, size);
168 } 173 }
169 174
175
176 void HttpOutput::AnswerBufferWithContentType(const void* buffer,
177 size_t size,
178 const std::string& contentType,
179 const HttpHandler::Arguments& cookies)
180 {
181 Header header;
182 PrepareOkHeader(header, contentType.c_str(), true, size, NULL);
183 PrepareCookies(header, cookies);
184 SendOkHeader(header);
185 Send(buffer, size);
186 }
187
188
189
170 void HttpOutput::Redirect(const std::string& path) 190 void HttpOutput::Redirect(const std::string& path)
171 { 191 {
172 std::string s = 192 std::string s =
173 "HTTP/1.1 301 " + std::string(HttpException::GetDescription(Orthanc_HttpStatus_301_MovedPermanently)) + 193 "HTTP/1.1 301 " + std::string(HttpException::GetDescription(Orthanc_HttpStatus_301_MovedPermanently)) +
174 "\r\nLocation: " + path + 194 "\r\nLocation: " + path +