Result of svn merge -r97546:97641 svn+ssh://svn/svn/linden/branches/apache-caps/merge-to-release into release. QAR-824
parent
13c96cc47b
commit
66739da164
|
|
@ -969,6 +969,9 @@ class LLSD(object):
|
|||
|
||||
undef = LLSD(None)
|
||||
|
||||
XML_MIME_TYPE = 'application/llsd+xml'
|
||||
BINARY_MIME_TYPE = 'application/llsd+binary'
|
||||
|
||||
# register converters for llsd in mulib, if it is available
|
||||
try:
|
||||
from mulib import stacked, mu
|
||||
|
|
@ -978,7 +981,7 @@ except:
|
|||
# mulib not available, don't print an error message since this is normal
|
||||
pass
|
||||
else:
|
||||
mu.add_parser(parse, 'application/llsd+xml')
|
||||
mu.add_parser(parse, XML_MIME_TYPE)
|
||||
mu.add_parser(parse, 'application/llsd+binary')
|
||||
|
||||
def llsd_convert_xml(llsd_stuff, request):
|
||||
|
|
@ -987,11 +990,58 @@ else:
|
|||
def llsd_convert_binary(llsd_stuff, request):
|
||||
request.write(format_binary(llsd_stuff))
|
||||
|
||||
for typ in [LLSD, dict, list, tuple, str, int, float, bool, unicode, type(None)]:
|
||||
stacked.add_producer(typ, llsd_convert_xml, 'application/llsd+xml')
|
||||
for typ in [LLSD, dict, list, tuple, str, int, long, float, bool, unicode, type(None)]:
|
||||
stacked.add_producer(typ, llsd_convert_xml, XML_MIME_TYPE)
|
||||
stacked.add_producer(typ, llsd_convert_xml, 'application/xml')
|
||||
stacked.add_producer(typ, llsd_convert_xml, 'text/xml')
|
||||
|
||||
stacked.add_producer(typ, llsd_convert_binary, 'application/llsd+binary')
|
||||
|
||||
stacked.add_producer(LLSD, llsd_convert_xml, '*/*')
|
||||
|
||||
# in case someone is using the legacy mu.xml wrapper, we need to
|
||||
# tell mu to produce application/xml or application/llsd+xml
|
||||
# (based on the accept header) from raw xml. Phoenix 2008-07-21
|
||||
stacked.add_producer(mu.xml, mu.produce_raw, XML_MIME_TYPE)
|
||||
stacked.add_producer(mu.xml, mu.produce_raw, 'application/xml')
|
||||
|
||||
|
||||
|
||||
# mulib wsgi stuff
|
||||
# try:
|
||||
# from mulib import mu, adapters
|
||||
#
|
||||
# # try some known attributes from mulib to be ultra-sure we've imported it
|
||||
# mu.get_current
|
||||
# adapters.handlers
|
||||
# except:
|
||||
# # mulib not available, don't print an error message since this is normal
|
||||
# pass
|
||||
# else:
|
||||
# def llsd_xml_handler(content_type):
|
||||
# def handle_llsd_xml(env, start_response):
|
||||
# llsd_stuff, _ = mu.get_current(env)
|
||||
# result = format_xml(llsd_stuff)
|
||||
# start_response("200 OK", [('Content-Type', content_type)])
|
||||
# env['mu.negotiated_type'] = content_type
|
||||
# yield result
|
||||
# return handle_llsd_xml
|
||||
#
|
||||
# def llsd_binary_handler(content_type):
|
||||
# def handle_llsd_binary(env, start_response):
|
||||
# llsd_stuff, _ = mu.get_current(env)
|
||||
# result = format_binary(llsd_stuff)
|
||||
# start_response("200 OK", [('Content-Type', content_type)])
|
||||
# env['mu.negotiated_type'] = content_type
|
||||
# yield result
|
||||
# return handle_llsd_binary
|
||||
#
|
||||
# adapters.DEFAULT_PARSERS[XML_MIME_TYPE] = parse
|
||||
|
||||
# for typ in [LLSD, dict, list, tuple, str, int, float, bool, unicode, type(None)]:
|
||||
# for content_type in (XML_MIME_TYPE, 'application/xml'):
|
||||
# adapters.handlers.set_handler(typ, llsd_xml_handler(content_type), content_type)
|
||||
#
|
||||
# adapters.handlers.set_handler(typ, llsd_binary_handler(BINARY_MIME_TYPE), BINARY_MIME_TYPE)
|
||||
#
|
||||
# adapters.handlers.set_handler(LLSD, llsd_xml_handler(XML_MIME_TYPE), '*/*')
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ request_ = suite.request_
|
|||
# import every httpc error exception into our namespace for convenience
|
||||
for x in httpc.status_to_error_map.itervalues():
|
||||
globals()[x.__name__] = x
|
||||
ConnectionError = httpc.ConnectionError
|
||||
Retriable = httpc.Retriable
|
||||
|
||||
for x in (httpc.ConnectionError,):
|
||||
globals()[x.__name__] = x
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ except ImportError:
|
|||
|
||||
llsd_parsers = {
|
||||
'application/json': json_decode,
|
||||
'application/llsd+binary': llsd.parse_binary,
|
||||
llsd.BINARY_MIME_TYPE: llsd.parse_binary,
|
||||
'application/llsd+notation': llsd.parse_notation,
|
||||
'application/llsd+xml': llsd.parse_xml,
|
||||
llsd.XML_MIME_TYPE: llsd.parse_xml,
|
||||
'application/xml': llsd.parse_xml,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -751,7 +751,7 @@ bool LLCurlRequest::post(const std::string& url, const LLSD& data, LLCurl::Respo
|
|||
easy->setopt(CURLOPT_POSTFIELDS, (void*)NULL);
|
||||
easy->setopt(CURLOPT_POSTFIELDSIZE, bytes);
|
||||
|
||||
easy->slist_append("Content-Type: application/xml");
|
||||
easy->slist_append("Content-Type: application/llsd+xml");
|
||||
easy->setHeaders();
|
||||
|
||||
lldebugs << "POSTING: " << bytes << " bytes." << llendl;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ namespace
|
|||
LLSDInjector(const LLSD& sd) : mSD(sd) {}
|
||||
virtual ~LLSDInjector() {}
|
||||
|
||||
const char* contentType() { return "application/xml"; }
|
||||
const char* contentType() { return "application/llsd+xml"; }
|
||||
|
||||
virtual EStatus process_impl(const LLChannelDescriptors& channels,
|
||||
buffer_ptr_t& buffer, bool& eos, LLSD& context, LLPumpIO* pump)
|
||||
|
|
@ -238,7 +238,8 @@ static void request(
|
|||
//the Pragma header it so gratuitously inserts
|
||||
//Before inserting the header, force libcurl
|
||||
//to not use the proxy (read: llurlrequest.cpp)
|
||||
if ((iter->first == "Pragma") && (iter->second.asString() == ""))
|
||||
static const std::string PRAGMA("Pragma");
|
||||
if ((iter->first == PRAGMA) && (iter->second.asString().empty()))
|
||||
{
|
||||
req->useProxy(false);
|
||||
}
|
||||
|
|
@ -247,6 +248,16 @@ static void request(
|
|||
req->addHeader(header.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if we have already set Accept or not. If no one
|
||||
// set it, set it to application/llsd+xml since that's what we
|
||||
// almost always want.
|
||||
static const std::string ACCEPT("Accept");
|
||||
if(!headers.has(ACCEPT))
|
||||
{
|
||||
req->addHeader("Accept: application/llsd+xml");
|
||||
}
|
||||
|
||||
req->setCallback(new LLHTTPClientURLAdaptor(responder));
|
||||
|
||||
if (method == LLURLRequest::HTTP_POST && gMessageSystem)
|
||||
|
|
@ -254,12 +265,22 @@ static void request(
|
|||
req->addHeader(llformat("X-SecondLife-UDP-Listen-Port: %d",
|
||||
gMessageSystem->mPort).c_str());
|
||||
}
|
||||
|
||||
|
||||
if (method == LLURLRequest::HTTP_PUT || method == LLURLRequest::HTTP_POST)
|
||||
{
|
||||
req->addHeader(llformat("Content-Type: %s",
|
||||
body_injector->contentType()).c_str());
|
||||
|
||||
static const std::string CONTENT_TYPE("Content-Type");
|
||||
if(!headers.has(CONTENT_TYPE))
|
||||
{
|
||||
// If the Content-Type header was passed in, it has
|
||||
// already been added as a header through req->addHeader
|
||||
// in the loop above. We defer to the caller's wisdom, but
|
||||
// if they did not specify a Content-Type, then ask the
|
||||
// injector.
|
||||
req->addHeader(
|
||||
llformat(
|
||||
"Content-Type: %s",
|
||||
body_injector->contentType()).c_str());
|
||||
}
|
||||
chain.push_back(LLIOPipe::ptr_t(body_injector));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl(
|
|||
case STATE_GOOD_RESULT:
|
||||
{
|
||||
LLSD headers = mHeaders;
|
||||
headers["Content-Type"] = "application/xml";
|
||||
headers["Content-Type"] = "application/llsd+xml";
|
||||
context[CONTEXT_RESPONSE][CONTEXT_HEADERS] = headers;
|
||||
LLBufferStream ostr(channels, buffer.get());
|
||||
LLSDSerialize::toXML(mGoodResult, ostr);
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ namespace tut
|
|||
"HTTP/1.0 200 OK\r\n");
|
||||
|
||||
ensure_contains("web/hello content type", result,
|
||||
"Content-Type: application/xml\r\n");
|
||||
"Content-Type: application/llsd+xml\r\n");
|
||||
|
||||
ensure_contains("web/hello content length", result,
|
||||
"Content-Length: 36\r\n");
|
||||
|
|
@ -232,7 +232,7 @@ namespace tut
|
|||
"HTTP/1.0 200 OK\r\n");
|
||||
|
||||
ensure_contains("web/echo content type", result,
|
||||
"Content-Type: application/xml\r\n");
|
||||
"Content-Type: application/llsd+xml\r\n");
|
||||
|
||||
ensure_contains("web/echo content length", result,
|
||||
"Content-Length: 35\r\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue