diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmessage/llhttpclient.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/linden/indra/llmessage/llhttpclient.cpp b/linden/indra/llmessage/llhttpclient.cpp index fc2612f..fb43861 100644 --- a/linden/indra/llmessage/llhttpclient.cpp +++ b/linden/indra/llmessage/llhttpclient.cpp | |||
@@ -106,7 +106,7 @@ namespace | |||
106 | LLSDInjector(const LLSD& sd) : mSD(sd) {} | 106 | LLSDInjector(const LLSD& sd) : mSD(sd) {} |
107 | virtual ~LLSDInjector() {} | 107 | virtual ~LLSDInjector() {} |
108 | 108 | ||
109 | const char* contentType() { return "application/xml"; } | 109 | const char* contentType() { return "application/llsd+xml"; } |
110 | 110 | ||
111 | virtual EStatus process_impl(const LLChannelDescriptors& channels, | 111 | virtual EStatus process_impl(const LLChannelDescriptors& channels, |
112 | buffer_ptr_t& buffer, bool& eos, LLSD& context, LLPumpIO* pump) | 112 | buffer_ptr_t& buffer, bool& eos, LLSD& context, LLPumpIO* pump) |
@@ -238,7 +238,8 @@ static void request( | |||
238 | //the Pragma header it so gratuitously inserts | 238 | //the Pragma header it so gratuitously inserts |
239 | //Before inserting the header, force libcurl | 239 | //Before inserting the header, force libcurl |
240 | //to not use the proxy (read: llurlrequest.cpp) | 240 | //to not use the proxy (read: llurlrequest.cpp) |
241 | if ((iter->first == "Pragma") && (iter->second.asString() == "")) | 241 | static const std::string PRAGMA("Pragma"); |
242 | if ((iter->first == PRAGMA) && (iter->second.asString().empty())) | ||
242 | { | 243 | { |
243 | req->useProxy(false); | 244 | req->useProxy(false); |
244 | } | 245 | } |
@@ -247,6 +248,19 @@ static void request( | |||
247 | req->addHeader(header.str().c_str()); | 248 | req->addHeader(header.str().c_str()); |
248 | } | 249 | } |
249 | } | 250 | } |
251 | |||
252 | // Check to see if we have already set Accept or not. If no one | ||
253 | // set it, set it to application/llsd+xml since that's what we | ||
254 | // almost always want. | ||
255 | if( method != LLURLRequest::HTTP_PUT && method != LLURLRequest::HTTP_POST ) | ||
256 | { | ||
257 | static const std::string ACCEPT("Accept"); | ||
258 | if(!headers.has(ACCEPT)) | ||
259 | { | ||
260 | req->addHeader("Accept: application/llsd+xml"); | ||
261 | } | ||
262 | } | ||
263 | |||
250 | req->setCallback(new LLHTTPClientURLAdaptor(responder)); | 264 | req->setCallback(new LLHTTPClientURLAdaptor(responder)); |
251 | 265 | ||
252 | if (method == LLURLRequest::HTTP_POST && gMessageSystem) | 266 | if (method == LLURLRequest::HTTP_POST && gMessageSystem) |
@@ -254,12 +268,22 @@ static void request( | |||
254 | req->addHeader(llformat("X-SecondLife-UDP-Listen-Port: %d", | 268 | req->addHeader(llformat("X-SecondLife-UDP-Listen-Port: %d", |
255 | gMessageSystem->mPort).c_str()); | 269 | gMessageSystem->mPort).c_str()); |
256 | } | 270 | } |
257 | 271 | ||
258 | if (method == LLURLRequest::HTTP_PUT || method == LLURLRequest::HTTP_POST) | 272 | if (method == LLURLRequest::HTTP_PUT || method == LLURLRequest::HTTP_POST) |
259 | { | 273 | { |
260 | req->addHeader(llformat("Content-Type: %s", | 274 | static const std::string CONTENT_TYPE("Content-Type"); |
261 | body_injector->contentType()).c_str()); | 275 | if(!headers.has(CONTENT_TYPE)) |
262 | 276 | { | |
277 | // If the Content-Type header was passed in, it has | ||
278 | // already been added as a header through req->addHeader | ||
279 | // in the loop above. We defer to the caller's wisdom, but | ||
280 | // if they did not specify a Content-Type, then ask the | ||
281 | // injector. | ||
282 | req->addHeader( | ||
283 | llformat( | ||
284 | "Content-Type: %s", | ||
285 | body_injector->contentType()).c_str()); | ||
286 | } | ||
263 | chain.push_back(LLIOPipe::ptr_t(body_injector)); | 287 | chain.push_back(LLIOPipe::ptr_t(body_injector)); |
264 | } | 288 | } |
265 | 289 | ||