diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 5540bb4a8f15690a91b335f64eb24bd3591133c8..94bfca64a3a7487e490c908bdd6a2ef6e635dc49 100644 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -647,10 +647,15 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) break; } + if (!mReqHeaders || !mReqHeaders->find("Connection")) + { + mCurlHeaders = curl_slist_append(mCurlHeaders, "Connection: keep-alive"); + } - // *TODO: Should this be 'Keep-Alive' ? - mCurlHeaders = curl_slist_append(mCurlHeaders, "Connection: keep-alive"); - mCurlHeaders = curl_slist_append(mCurlHeaders, "Keep-alive: 300"); + if (!mReqHeaders || !mReqHeaders->find("Keep-Alive")) + { + mCurlHeaders = curl_slist_append(mCurlHeaders, "Keep-Alive: 300"); + } // Tracing if (mTracing >= HTTP_TRACE_CURL_HEADERS) diff --git a/indra/llcorehttp/httpheaders.cpp b/indra/llcorehttp/httpheaders.cpp index de35eeca0893777f29c2e3eeca8787b92cd69216..1c0381ccb6e9d9858110023d4d0f02835f9e2b26 100644 --- a/indra/llcorehttp/httpheaders.cpp +++ b/indra/llcorehttp/httpheaders.cpp @@ -42,12 +42,30 @@ HttpHeaders::clear() void HttpHeaders::append(const std::string & name, const std::string & value) { + for (reverse_iterator iter(rbegin()), iend(rend()); iend != iter; ++iter) + { + if ((*iter).first == name) + { + iter->second = value; + return; + } + } + mHeaders.push_back(value_type(name, value)); } void HttpHeaders::append(const char * name, const char * value) { + for (reverse_iterator iter(rbegin()), iend(rend()); iend != iter; ++iter) + { + if ((*iter).first == name) + { + iter->second = value; + return; + } + } + mHeaders.push_back(value_type(name, value)); } diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index 11f6b71f2f2195641bfe87a15e4949111371e327..9364161da1bd0bf9c48be35df229f47f774705bc 100644 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -2170,8 +2170,8 @@ void HttpRequestTestObjectType::test<19>() // headers headers = HttpHeaders::ptr_t(new HttpHeaders); - headers->append("Keep-Alive", "120"); - headers->append("Accept-encoding", "deflate"); + headers->append("Keep-Alive", "120"); + headers->append("Accept-Encoding", "deflate"); headers->append("Accept", "text/plain"); // Issue a GET with modified headers @@ -2352,10 +2352,10 @@ void HttpRequestTestObjectType::test<20>() // headers headers = HttpHeaders::ptr_t(new HttpHeaders()); - headers->append("keep-Alive", "120"); + headers->append("Keep-Alive", "120"); headers->append("Accept", "text/html"); - headers->append("content-type", "application/llsd+xml"); - headers->append("cache-control", "no-store"); + headers->append("Content-Type", "application/llsd+xml"); + headers->append("Cache-Control", "no-store"); // And a buffer array const char * msg("<xml><llsd><string>It was the best of times, it was the worst of times.</string></llsd></xml>"); @@ -2556,9 +2556,9 @@ void HttpRequestTestObjectType::test<21>() // headers headers = HttpHeaders::ptr_t(new HttpHeaders); - headers->append("content-type", "text/plain"); - headers->append("content-type", "text/html"); - headers->append("content-type", "application/llsd+xml"); + headers->append("Content-Type", "text/plain"); + headers->append("Content-Type", "text/html"); + headers->append("Content-Type", "application/llsd+xml"); // And a buffer array const char * msg("<xml><llsd><string>It was the best of times, it was the worst of times.</string></llsd></xml>"); diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 60ca70ea74351d7aa00504e4c01d7f1ae50b33c8..e8b74e6ef7e8c423a11f171f5728d08e24aad44b 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -214,7 +214,7 @@ namespace LLMarketplaceImport httpOpts->setFollowRedirects(true); httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "*/*"); - httpHeaders->append(HTTP_OUT_HEADER_CONNECTION, "Keep-Alive"); + httpHeaders->append(HTTP_OUT_HEADER_CONNECTION, "keep-alive"); httpHeaders->append(HTTP_OUT_HEADER_COOKIE, sMarketplaceCookie); httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_XML); httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, LLViewerMedia::getInstance()->getCurrentUserAgent()); @@ -854,8 +854,8 @@ void LLMarketplaceData::getSLMListingsCoro(LLUUID folderId) LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); - httpHeaders->append("Accept", "application/json"); - httpHeaders->append("Content-Type", "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "application/json"); std::string url = getSLMConnectURL("/listings"); @@ -916,8 +916,8 @@ void LLMarketplaceData::getSingleListingCoro(S32 listingId, LLUUID folderId) LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); - httpHeaders->append("Accept", "application/json"); - httpHeaders->append("Content-Type", "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "application/json"); std::string url = getSLMConnectURL("/listing/") + llformat("%d", listingId); @@ -984,8 +984,8 @@ void LLMarketplaceData::createSLMListingCoro(LLUUID folderId, LLUUID versionId, LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); - httpHeaders->append("Accept", "application/json"); - httpHeaders->append("Content-Type", "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "application/json"); LLViewerInventoryCategory* category = gInventory.getCategory(folderId); LLSD invInfo; @@ -1049,8 +1049,8 @@ void LLMarketplaceData::updateSLMListingCoro(LLUUID folderId, S32 listingId, LLU LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); - httpHeaders->append("Accept", "application/json"); - httpHeaders->append("Content-Type", "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "application/json"); LLSD invInfo; invInfo["listing_folder_id"] = folderId; @@ -1128,8 +1128,8 @@ void LLMarketplaceData::associateSLMListingCoro(LLUUID folderId, S32 listingId, LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); - httpHeaders->append("Accept", "application/json"); - httpHeaders->append("Content-Type", "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "application/json"); LLSD invInfo; invInfo["listing_folder_id"] = folderId; @@ -1206,8 +1206,8 @@ void LLMarketplaceData::deleteSLMListingCoro(S32 listingId) LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); - httpHeaders->append("Accept", "application/json"); - httpHeaders->append("Content-Type", "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, "application/json"); + httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "application/json"); std::string url = getSLMConnectURL("/listing/") + llformat("%d", listingId); LLUUID folderId = getListingFolder(listingId);