Mercurial > hg > orthanc
comparison Core/RestApi/RestApi.cpp @ 1515:c94353fbd4e9
cont http compression
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 10 Aug 2015 17:18:36 +0200 |
parents | d73a2178b319 |
children | 4f8c8ef114db |
comparison
equal
deleted
inserted
replaced
1514:d73a2178b319 | 1515:c94353fbd4e9 |
---|---|
192 } | 192 } |
193 } | 193 } |
194 } | 194 } |
195 #endif | 195 #endif |
196 | 196 |
197 { | 197 std::set<HttpCompression> compressions; |
198 // Look if the client wishes HTTP compression | 198 GetAcceptedCompressions(compressions, headers); |
199 // https://en.wikipedia.org/wiki/HTTP_compression | 199 |
200 Arguments::const_iterator it = headers.find("accept-encoding"); | 200 if (compressions.find(HttpCompression_Deflate) != compressions.end()) |
201 if (it != headers.end()) | 201 { |
202 { | 202 wrappedOutput.AllowDeflateCompression(true); |
203 std::vector<std::string> encodings; | 203 } |
204 Toolbox::TokenizeString(encodings, it->second, ','); | 204 |
205 for (size_t i = 0; i < encodings.size(); i++) | 205 if (compressions.find(HttpCompression_Gzip) != compressions.end()) |
206 { | 206 { |
207 std::string s = Toolbox::StripSpaces(encodings[i]); | 207 wrappedOutput.AllowGzipCompression(true); |
208 | 208 } |
209 if (s == "deflate") | 209 |
210 { | |
211 wrappedOutput.AllowDeflateCompression(true); | |
212 } | |
213 else if (s == "gzip") | |
214 { | |
215 wrappedOutput.AllowGzipCompression(true); | |
216 } | |
217 } | |
218 } | |
219 } | |
220 | 210 |
221 Arguments compiled; | 211 Arguments compiled; |
222 HttpToolbox::CompileGetArguments(compiled, getArguments); | 212 HttpToolbox::CompileGetArguments(compiled, getArguments); |
223 | 213 |
224 HttpHandlerVisitor visitor(*this, wrappedOutput, method, headers, compiled, bodyData, bodySize); | 214 HttpHandlerVisitor visitor(*this, wrappedOutput, method, headers, compiled, bodyData, bodySize); |