@Override
protected void addProperties(DefaultMuleMessage message, Object transportMessage) throws Exception
{
String method;
HttpVersion httpVersion;
String uri;
String statusCode = null;
Map<String, Object> headers;
Map<String, Object> httpHeaders = new HashMap<String, Object>();
Map<String, Object> queryParameters = new HashMap<String, Object>();
if (transportMessage instanceof HttpRequest)
{
HttpRequest httpRequest = (HttpRequest) transportMessage;
method = httpRequest.getRequestLine().getMethod();
httpVersion = httpRequest.getRequestLine().getHttpVersion();
uri = httpRequest.getRequestLine().getUri();
headers = convertHeadersToMap(httpRequest.getHeaders(), uri);
convertMultiPartHeaders(headers);
}
else if (transportMessage instanceof HttpMethod)
{
HttpMethod httpMethod = (HttpMethod) transportMessage;
method = httpMethod.getName();
httpVersion = HttpVersion.parse(httpMethod.getStatusLine().getHttpVersion());
uri = httpMethod.getURI().toString();
statusCode = String.valueOf(httpMethod.getStatusCode());
headers = convertHeadersToMap(httpMethod.getResponseHeaders(), uri);
}
else
{
// This should never happen because of the supported type checking in our superclass
throw new MessageTypeNotSupportedException(transportMessage, getClass());
}
rewriteConnectionAndKeepAliveHeaders(headers);
headers = processIncomingHeaders(headers);
httpHeaders.put(HttpConnector.HTTP_HEADERS, new HashMap<String, Object>(headers));
String encoding = getEncoding(headers);
queryParameters.put(HttpConnector.HTTP_QUERY_PARAMS, processQueryParams(uri, encoding));
//Make any URI params available ans inbound message headers
addUriParamsAsHeaders(headers, uri);
headers.put(HttpConnector.HTTP_METHOD_PROPERTY, method);
headers.put(HttpConnector.HTTP_REQUEST_PROPERTY, uri);
headers.put(HttpConnector.HTTP_VERSION_PROPERTY, httpVersion.toString());
if (enableCookies)
{
headers.put(HttpConnector.HTTP_COOKIE_SPEC_PROPERTY, cookieSpec);
}