// basic request
Boolean noEntityBody = (Boolean) msgContext.getProperty(RelayConstants.NO_ENTITY_BODY);
EndpointReference epr = RelayTransportUtils.getDestinationEPR(msgContext);
URL url = new URL(epr.getAddress());
TargetRequest request = new TargetRequest(configuration, url, httpMethod,
noEntityBody == null || !noEntityBody);
// headers
RelayTransportUtils.removeUnwantedHeaders(msgContext,
configuration.isPreserveServerHeader(),
configuration.isPreserveUserAgentHeader());
Object o = msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
if (o != null && o instanceof Map) {
Map headers = (Map) o;
for (Object o1 : headers.keySet()) {
Object value = headers.get(o1);
if (o1 instanceof String && value != null && value instanceof String) {
if (!HTTPConstants.HEADER_HOST.equalsIgnoreCase((String) o1)) {
request.addHeader((String) o1, (String) value);
}
}
}
}
// version
String forceHttp10 = (String) msgContext.getProperty(RelayConstants.FORCE_HTTP_1_0);
if ("true".equals(forceHttp10)) {
request.setVersion(HttpVersion.HTTP_1_0);
}
// keep alive
String noKeepAlie = (String) msgContext.getProperty(RelayConstants.NO_KEEPALIVE);
if ("true".equals(noKeepAlie)) {
request.setKeepAlive(false);
}
// port
int port = url.getPort();
request.setPort(port != -1 ? port : 80);
// chunk
String disableChunking = (String) msgContext.getProperty(
RelayConstants.DISABLE_CHUNKING);
if ("true".equals(disableChunking)) {
request.setChunk(false);
}
// full url
String fullUrl = (String) msgContext.getProperty(RelayConstants.FULL_URI);
if ("true".equals(fullUrl)) {
request.setFullUrl(true);
}
return request;
} catch (MalformedURLException e) {
handleException("Invalid to address" + msgContext.getTo().getAddress(), e);