summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2015-06-04 17:36:24 -0700
committerRider Linden <rider@lindenlab.com>2015-06-04 17:36:24 -0700
commitd0d58c41b48f8a2a0e18610b577059ee8419be5c (patch)
tree459c65b14aab1ced1e55c6051ce7650528ab4236 /indra/llmessage
parentd034c4f2445eb3095bd17aef421c367bb913af39 (diff)
Default headers added.
Group manager finished conversion. Outfit folders coverted.
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llcorehttputil.cpp38
-rw-r--r--indra/llmessage/llcorehttputil.h9
2 files changed, 40 insertions, 7 deletions
diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp
index c4a7e9040a..1fd7e7be2e 100644
--- a/indra/llmessage/llcorehttputil.cpp
+++ b/indra/llmessage/llcorehttputil.cpp
@@ -37,6 +37,8 @@
#include "llsdserialize.h"
#include "reader.h"
+#include "message.h" // for getting the port
+
using namespace LLCore;
@@ -243,11 +245,10 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons
result = LLSD::emptyMap();
LL_WARNS()
<< "\n--------------------------------------------------------------------------\n"
- << " Error[" << status.toULong() << "] cannot access url '" << response->getRequestURL()
+ << " Error[" << status.getType() << "] cannot access url '" << response->getRequestURL()
<< "' because " << status.toString()
<< "\n--------------------------------------------------------------------------"
<< LL_ENDL;
-
}
else
{
@@ -578,8 +579,10 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque
LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
HttpCoroHandler::ptr_t &handler)
{
- //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL;
HttpRequestPumper pumper(request);
+
+ checkDefaultHeaders(headers);
+
// The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = requestPostWithLLSD(request,
@@ -623,8 +626,10 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque
LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
HttpCoroHandler::ptr_t &handler)
{
- //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL;
HttpRequestPumper pumper(request);
+
+ checkDefaultHeaders(headers);
+
// The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(),
@@ -658,8 +663,10 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpReques
LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
HttpCoroHandler::ptr_t &handler)
{
- //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL;
HttpRequestPumper pumper(request);
+
+ checkDefaultHeaders(headers);
+
// The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = requestPutWithLLSD(request,
@@ -713,8 +720,9 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques
LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
HttpCoroHandler::ptr_t &handler)
{
- //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL;
HttpRequestPumper pumper(request);
+ checkDefaultHeaders(headers);
+
// The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority,
@@ -747,8 +755,9 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq
const std::string & url, LLCore::HttpOptions::ptr_t &options,
LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler)
{
- //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL;
HttpRequestPumper pumper(request);
+
+ checkDefaultHeaders(headers);
// The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId, mPriority,
@@ -766,6 +775,21 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq
return results;
}
+void HttpCoroutineAdapter::checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers)
+{
+ if (!headers)
+ headers.reset(new LLCore::HttpHeaders);
+ if (!headers->find(HTTP_OUT_HEADER_ACCEPT))
+ {
+ headers->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_LLSD_XML);
+ }
+
+ if (!headers->find("X-SecondLife-UDP-Listen-Port") && gMessageSystem)
+ {
+ headers->append("X-SecondLife-UDP-Listen-Port", llformat("%d", gMessageSystem->mPort));
+ }
+}
+
void HttpCoroutineAdapter::cancelYieldingOperation()
{
diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h
index 53c8112395..e6c9d2463c 100644
--- a/indra/llmessage/llcorehttputil.h
+++ b/indra/llmessage/llcorehttputil.h
@@ -286,6 +286,13 @@ private:
/// will be automatically pumped and the method will return with an LLSD describing
/// the result of the operation. See HttpCoroHandler for a description of the
/// decoration done to the returned LLSD.
+///
+/// Posting through the adapter will automatically add the following headers to
+/// the request if they have not been previously specified in a supplied
+/// HttpHeaders object:
+/// "Accept=application/llsd+xml"
+/// "X-SecondLife-UDP-Listen-Port=###"
+///
class HttpCoroutineAdapter
{
public:
@@ -467,6 +474,8 @@ private:
static void trivialGetCoro(LLCoros::self& self, std::string url, completionCallback_t success, completionCallback_t failure);
static void trivialPostCoro(LLCoros::self& self, std::string url, LLSD postData, completionCallback_t success, completionCallback_t failure);
+ void checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers);
+
std::string mAdapterName;
LLCore::HttpRequest::priority_t mPriority;
LLCore::HttpRequest::policy_t mPolicyId;