List of usage examples for org.apache.http.protocol HTTP CONTENT_LEN
String CONTENT_LEN
To view the source code for org.apache.http.protocol HTTP CONTENT_LEN.
Click Source Link
From source file:org.apache.synapse.transport.nhttp.ServerWorker.java
/** * Process the incoming request/*from w w w. j a v a 2s. c o m*/ */ @SuppressWarnings({ "unchecked" }) public void run() { CustomLogSetter.getInstance().clearThreadLocalContent(); conn.getContext().setAttribute(NhttpConstants.SERVER_WORKER_START_TIME, System.currentTimeMillis()); conn.getContext().setAttribute(NhttpConstants.SERVER_WORKER_THREAD_ID, Thread.currentThread().getId()); String method = request.getRequestLine().getMethod().toUpperCase(); msgContext.setProperty(Constants.Configuration.HTTP_METHOD, request.getRequestLine().getMethod()); if (NHttpConfiguration.getInstance().isHttpMethodDisabled(method)) { handleException("Unsupported method : " + method, null); } //String uri = request.getRequestLine().getUri(); String oriUri = request.getRequestLine().getUri(); String restUrlPostfix = NhttpUtil.getRestUrlPostfix(oriUri, cfgCtx.getServicePath()); msgContext.setProperty(NhttpConstants.REST_URL_POSTFIX, restUrlPostfix); String servicePrefix = oriUri.substring(0, oriUri.indexOf(restUrlPostfix)); if (servicePrefix.indexOf("://") == -1) { HttpInetConnection inetConn = (HttpInetConnection) conn; InetAddress localAddr = inetConn.getLocalAddress(); if (localAddr != null) { servicePrefix = schemeName + "://" + localAddr.getHostName() + ":" + inetConn.getLocalPort() + servicePrefix; } } msgContext.setProperty(NhttpConstants.SERVICE_PREFIX, servicePrefix); if ("GET".equals(method)) { httpGetRequestProcessor.process(request, response, msgContext, conn, os, isRestDispatching); } else if ("POST".equals(method)) { processEntityEnclosingMethod(); } else if ("PUT".equals(method)) { processEntityEnclosingMethod(); } else if ("HEAD".equals(method)) { processNonEntityEnclosingMethod(); } else if ("OPTIONS".equals(method)) { processNonEntityEnclosingMethod(); } else if ("DELETE".equals(method)) { processGetAndDelete("DELETE"); } else if ("TRACE".equals(method)) { processNonEntityEnclosingMethod(); } else if ("PATCH".equals(method)) { processEntityEnclosingMethod(); } else { handleException("Unsupported method : " + method, null); } // here the RequestResponseTransport plays an important role when it comes to // dual channel invocation. This is becasue we need to ACK to the request once the request // is received to synapse. Otherwise we will not be able to support the single channel // invocation within the actual service and synapse for a dual channel request from the // client. if (isAckRequired()) { String respWritten = ""; if (msgContext.getOperationContext() != null) { respWritten = (String) msgContext.getOperationContext().getProperty(Constants.RESPONSE_WRITTEN); } boolean respWillFollow = !Constants.VALUE_TRUE.equals(respWritten) && !"SKIP".equals(respWritten); boolean acked = (((RequestResponseTransport) msgContext .getProperty(RequestResponseTransport.TRANSPORT_CONTROL)) .getStatus() == RequestResponseTransport.RequestResponseTransportStatus.ACKED); boolean forced = msgContext.isPropertyTrue(NhttpConstants.FORCE_SC_ACCEPTED); boolean nioAck = msgContext.isPropertyTrue("NIO-ACK-Requested", false); if (respWillFollow || acked || forced || nioAck) { if (!nioAck) { if (log.isDebugEnabled()) { log.debug("Sending 202 Accepted response for MessageID : " + msgContext.getMessageID() + " response written : " + respWritten + " response will follow : " + respWillFollow + " acked : " + acked + " forced ack : " + forced); } response.setStatusCode(HttpStatus.SC_ACCEPTED); } else { if (log.isDebugEnabled()) { log.debug( "Sending ACK response with status " + msgContext.getProperty(NhttpConstants.HTTP_SC) + ", for MessageID : " + msgContext.getMessageID()); } response.setStatusCode( Integer.parseInt(msgContext.getProperty(NhttpConstants.HTTP_SC).toString())); Map<String, String> responseHeaders = (Map<String, String>) msgContext .getProperty(MessageContext.TRANSPORT_HEADERS); if (responseHeaders != null) { for (String headerName : responseHeaders.keySet()) { response.addHeader(headerName, responseHeaders.get(headerName)); String excessProp = NhttpConstants.EXCESS_TRANSPORT_HEADERS; Map map = (Map) msgContext.getProperty(excessProp); if (map != null) { log.debug("Number of excess values for " + headerName + " header is : " + ((Collection) (map.get(headerName))).size()); for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) { String key = (String) iterator.next(); for (String excessVal : (Collection<String>) map.get(key)) { response.addHeader(headerName, (String) excessVal); } } } } } } if (metrics != null) { metrics.incrementMessagesSent(); } try { /* * Remove Content-Length and Transfer-Encoding headers, if already present. * */ response.removeHeaders(HTTP.TRANSFER_ENCODING); response.removeHeaders(HTTP.CONTENT_LEN); serverHandler.commitResponse(conn, response); } catch (HttpException e) { if (metrics != null) { metrics.incrementFaultsSending(); } handleException("Unexpected HTTP protocol error : " + e.getMessage(), e); } catch (ConnectionClosedException e) { if (metrics != null) { metrics.incrementFaultsSending(); } log.warn("Connection closed by client (Connection closed)"); } catch (IllegalStateException e) { if (metrics != null) { metrics.incrementFaultsSending(); } log.warn("Connection closed by client (Buffer closed)"); } catch (IOException e) { if (metrics != null) { metrics.incrementFaultsSending(); } handleException("IO Error sending response message", e); } catch (Exception e) { if (metrics != null) { metrics.incrementFaultsSending(); } handleException("General Error sending response message", e); } if (is != null) { try { is.close(); } catch (IOException ignore) { } } // make sure that the output stream is flushed and closed properly try { os.flush(); os.close(); } catch (IOException ignore) { } } } }
From source file:org.apache.synapse.transport.nhttp.ServerHandler.java
/** * Commit the response to the connection. Processes the response through the configured * HttpProcessor and submits it to be sent out. Re-Throws exceptions, after closing connections * @param conn the connection being processed * @param response the response to commit over the connection * @throws IOException if an IO error occurs while sending the response * @throws HttpException if a HTTP protocol violation occurs while sending the response *//*from w w w. j a v a2 s . co m*/ public void commitResponse(final NHttpServerConnection conn, final HttpResponse response) throws IOException, HttpException { try { BasicHttpEntity entity = (BasicHttpEntity) response.getEntity(); Header[] headers = response.getAllHeaders(); int contentLength = -1; if (canResponseHaveBody(response, conn)) { if (entity == null) { entity = new BasicHttpEntity(); } for (Header header : headers) { if (header.getName().equals(HTTP.CONTENT_LEN) && Integer.parseInt(header.getValue()) > 0) { contentLength = Integer.parseInt(header.getValue()); response.removeHeader(header); } } if (contentLength != -1) { entity.setChunked(false); entity.setContentLength(contentLength); } else { entity.setChunked(true); } } else { if (entity != null) { entity.setChunked(false); entity.setContentLength(contentLength); } } response.setEntity(entity); conn.suspendInput(); HttpContext context = conn.getContext(); httpProcessor.process(response, context); conn.getContext().setAttribute(NhttpConstants.RES_TO_CLIENT_WRITE_START_TIME, System.currentTimeMillis()); conn.submitResponse(response); } catch (HttpException e) { shutdownConnection(conn, true, e.getMessage()); throw e; } catch (IOException e) { shutdownConnection(conn, true, e.getMessage()); throw e; } }
From source file:org.apache.synapse.transport.nhttp.HttpCoreNIOSender.java
/** * Extract the content length from the incoming message * * @param msgContext current MessageContext * @return the length of the message/*from w ww .j a v a 2 s . c o m*/ */ private int extractContentLength(MessageContext msgContext) { Map headers = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS); if (headers == null || headers.isEmpty()) { return -1; } for (Object o : headers.keySet()) { String headerName = (String) o; if (HTTP.CONTENT_LEN.equalsIgnoreCase(headerName)) { Object value = headers.get(headerName); if (value != null && value instanceof String) { try { return Integer.parseInt((String) value); } catch (NumberFormatException e) { return -1; } } } } return -1; }
From source file:org.apache.axis2.transport.http.AbstractHTTPSender.java
/** * Remove unwanted headers from the transport headers map of outgoing request. These are headers which * should be dictated by the transport and not the user. We remove these as these may get * copied from the request messages/*from w w w . j a v a 2s .c om*/ * * @param msgContext the Axis2 Message context from which these headers should be removed */ private void removeUnwantedHeaders(MessageContext msgContext) { Map headers = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS); if (headers == null || headers.isEmpty()) { return; } Iterator iter = headers.keySet().iterator(); while (iter.hasNext()) { String headerName = (String) iter.next(); if (HTTP.CONN_DIRECTIVE.equalsIgnoreCase(headerName) || HTTP.TRANSFER_ENCODING.equalsIgnoreCase(headerName) || HTTP.DATE_HEADER.equalsIgnoreCase(headerName) || HTTP.CONTENT_TYPE.equalsIgnoreCase(headerName) || HTTP.CONTENT_LEN.equalsIgnoreCase(headerName)) { iter.remove(); } } }
From source file:org.apache.synapse.transport.nhttp.ClientHandler.java
/** * Perform processing of the received response though Axis2 * * @param conn HTTP connection to be processed * @param context HTTP context associated with the connection * @param response HTTP response associated with the connection */// w w w. j av a 2 s . c o m private void processResponse(final NHttpClientConnection conn, HttpContext context, HttpResponse response) { ContentInputBuffer inputBuffer = null; MessageContext outMsgContext = (MessageContext) context.getAttribute(OUTGOING_MESSAGE_CONTEXT); String endptPrefix = (String) context.getAttribute(NhttpConstants.ENDPOINT_PREFIX); String requestMethod = (String) context.getAttribute(NhttpConstants.HTTP_REQ_METHOD); int statusCode = response.getStatusLine().getStatusCode(); boolean expectEntityBody = false; if (!"HEAD".equals(requestMethod) && !"OPTIONS".equals(requestMethod) && statusCode >= HttpStatus.SC_OK && statusCode != HttpStatus.SC_NO_CONTENT && statusCode != HttpStatus.SC_NOT_MODIFIED && statusCode != HttpStatus.SC_RESET_CONTENT) { expectEntityBody = true; } else if (NhttpConstants.HTTP_HEAD.equals(requestMethod)) { // When invoking http HEAD request esb set content length as 0 to response header. Since there is no message // body content length cannot be calculated inside synapse. Hence additional two headers are added to // which contains content length of the backend response and the request method. These headers are removed // before submitting the actual response. response.addHeader(NhttpConstants.HTTP_REQUEST_METHOD, requestMethod); if (response.getFirstHeader(HTTP.CONTENT_LEN) != null) { response.addHeader(NhttpConstants.ORIGINAL_CONTENT_LEN, response.getFirstHeader(HTTP.CONTENT_LEN).getValue()); } } if (expectEntityBody) { inputBuffer = new SharedInputBuffer(cfg.getBufferSize(), conn, allocator); context.setAttribute(RESPONSE_SINK_BUFFER, inputBuffer); BasicHttpEntity entity = new BasicHttpEntity(); if (response.getStatusLine().getProtocolVersion().greaterEquals(HttpVersion.HTTP_1_1)) { entity.setChunked(true); } response.setEntity(entity); context.setAttribute(ExecutionContext.HTTP_RESPONSE, response); } else { conn.resetInput(); conn.resetOutput(); if (context.getAttribute(NhttpConstants.DISCARD_ON_COMPLETE) != null || !connStrategy.keepAlive(response, context)) { try { // this is a connection we should not re-use connpool.forget(conn); shutdownConnection(conn, false, null); context.removeAttribute(RESPONSE_SINK_BUFFER); context.removeAttribute(REQUEST_SOURCE_BUFFER); } catch (Exception ignore) { } } else { connpool.release(conn); } } workerPool .execute(new ClientWorker(cfgCtx, inputBuffer == null ? null : new ContentInputStream(inputBuffer), response, outMsgContext, endptPrefix)); }
From source file:org.apache.synapse.transport.nhttp.ClientHandler.java
/** * Process a new connection over an existing TCP connection or new * /*w w w . j a va2 s. c om*/ * @param conn HTTP connection to be processed * @param axis2Req axis2 representation of the message in the connection * @throws ConnectionClosedException if the connection is closed */ private void processConnection(final NHttpClientConnection conn, final Axis2HttpRequest axis2Req) throws ConnectionClosedException { // record start time of request ClientConnectionDebug cd = (ClientConnectionDebug) axis2Req.getMsgContext() .getProperty(CLIENT_CONNECTION_DEBUG); if (cd != null) { cd.recordRequestStartTime(conn, axis2Req); conn.getContext().setAttribute(CLIENT_CONNECTION_DEBUG, cd); } try { // Reset connection metrics conn.getMetrics().reset(); HttpContext context = conn.getContext(); ContentOutputBuffer outputBuffer = new SharedOutputBuffer(cfg.getBufferSize(), conn, allocator); axis2Req.setOutputBuffer(outputBuffer); context.setAttribute(REQUEST_SOURCE_BUFFER, outputBuffer); HttpRoute route = axis2Req.getRoute(); context.setAttribute(AXIS2_HTTP_REQUEST, axis2Req); context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn); context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, route.getTargetHost()); context.setAttribute(OUTGOING_MESSAGE_CONTEXT, axis2Req.getMsgContext()); HttpRequest request = axis2Req.getRequest(); request.setParams(new DefaultedHttpParams(request.getParams(), this.params)); /* * Remove Content-Length and Transfer-Encoding headers, if already present. * */ request.removeHeaders(HTTP.TRANSFER_ENCODING); request.removeHeaders(HTTP.CONTENT_LEN); this.httpProcessor.process(request, context); if (proxyauthenticator != null && route.getProxyHost() != null && !route.isTunnelled()) { proxyauthenticator.authenticatePreemptively(request, context); } if (axis2Req.getTimeout() > 0) { conn.setSocketTimeout(axis2Req.getTimeout()); } context.setAttribute(NhttpConstants.ENDPOINT_PREFIX, axis2Req.getEndpointURLPrefix()); context.setAttribute(NhttpConstants.HTTP_REQ_METHOD, request.getRequestLine().getMethod()); context.setAttribute(ExecutionContext.HTTP_REQUEST, request); setServerContextAttribute(NhttpConstants.REQ_DEPARTURE_TIME, System.currentTimeMillis(), conn); setServerContextAttribute(NhttpConstants.REQ_TO_BACKEND_WRITE_START_TIME, System.currentTimeMillis(), conn); conn.submitRequest(request); } catch (ConnectionClosedException e) { throw e; } catch (IOException e) { if (metrics != null) { metrics.incrementFaultsSending(); } handleException("I/O Error submitting request : " + e.getMessage(), e, conn); } catch (HttpException e) { if (metrics != null) { metrics.incrementFaultsSending(); } handleException("HTTP protocol error submitting request : " + e.getMessage(), e, conn); } finally { synchronized (axis2Req) { axis2Req.setReadyToStream(true); axis2Req.notifyAll(); } } }
From source file:org.apache.synapse.transport.passthru.ClientWorker.java
private String inferContentType() { //Check whether server sent Content-Type in different case Map<String, String> headers = response.getHeaders(); for (String header : headers.keySet()) { if (HTTP.CONTENT_TYPE.equalsIgnoreCase(header)) { return headers.get(header); }/*w w w. j a v a2 s . com*/ } String cType = response.getHeader("content-type"); if (cType != null) { return cType; } cType = response.getHeader("Content-type"); if (cType != null) { return cType; } // Try to get the content type from the message context Object cTypeProperty = responseMsgCtx.getProperty(PassThroughConstants.CONTENT_TYPE); if (cTypeProperty != null) { return cTypeProperty.toString(); } // Try to get the content type from the axis configuration Parameter cTypeParam = targetConfiguration.getConfigurationContext().getAxisConfiguration() .getParameter(PassThroughConstants.CONTENT_TYPE); if (cTypeParam != null) { return cTypeParam.getValue().toString(); } // When the response from backend does not have the body(Content-Length is 0 ) // and Content-Type is not set; ESB should not do any modification to the response and pass-through as it is. if (headers.get(HTTP.CONTENT_LEN) == null || "0".equals(headers.get(HTTP.CONTENT_LEN))) { return null; } // Unable to determine the content type - Return default value return PassThroughConstants.DEFAULT_CONTENT_TYPE; }
From source file:org.apache.synapse.transport.passthru.SourceResponse.java
/** * Starts the response by writing the headers * @param conn connection// w ww. j a v a 2 s . co m * @throws java.io.IOException if an error occurs * @throws org.apache.http.HttpException if an error occurs */ public void start(NHttpServerConnection conn) throws IOException, HttpException { // create the response response = sourceConfiguration.getResponseFactory().newHttpResponse(request.getVersion(), this.status, request.getConnection().getContext()); if (statusLine != null) { response.setStatusLine(version, status, statusLine); } else { response.setStatusCode(status); } BasicHttpEntity entity = null; if (canResponseHaveBody(request.getRequest(), response)) { entity = new BasicHttpEntity(); int contentLength = -1; String contentLengthHeader = null; if (headers.get(HTTP.CONTENT_LEN) != null && headers.get(HTTP.CONTENT_LEN).size() > 0) { contentLengthHeader = headers.get(HTTP.CONTENT_LEN).first(); } if (contentLengthHeader != null) { contentLength = Integer.parseInt(contentLengthHeader); headers.remove(HTTP.CONTENT_LEN); } if (contentLength != -1) { entity.setChunked(false); entity.setContentLength(contentLength); } else { entity.setChunked(true); } } response.setEntity(entity); // set any transport headers Set<Map.Entry<String, TreeSet<String>>> entries = headers.entrySet(); for (Map.Entry<String, TreeSet<String>> entry : entries) { if (entry.getKey() != null) { Iterator<String> i = entry.getValue().iterator(); while (i.hasNext()) { response.addHeader(entry.getKey(), i.next()); } } } response.setParams(new DefaultedHttpParams(response.getParams(), sourceConfiguration.getHttpParams())); SourceContext.updateState(conn, ProtocolState.RESPONSE_HEAD); // Pre-process HTTP response conn.getContext().setAttribute(ExecutionContext.HTTP_CONNECTION, conn); conn.getContext().setAttribute(ExecutionContext.HTTP_RESPONSE, response); conn.getContext().setAttribute(ExecutionContext.HTTP_REQUEST, SourceContext.getRequest(conn).getRequest()); sourceConfiguration.getHttpProcessor().process(response, conn.getContext()); conn.submitResponse(response); // Handle non entity body responses if (entity == null) { hasEntity = false; // Reset connection state sourceConfiguration.getSourceConnections().releaseConnection(conn); // Make ready to deal with a new request conn.requestInput(); } }
From source file:org.apache.synapse.transport.passthru.SourceResponse.java
public void checkResponseChunkDisable(MessageContext responseMsgContext) throws IOException { if (responseMsgContext.isPropertyTrue(PassThroughConstants.DISABLE_CHUNKING, false)) { if (!responseMsgContext.isPropertyTrue(PassThroughConstants.MESSAGE_BUILDER_INVOKED, false)) { try { RelayUtils.buildMessage(responseMsgContext, false); responseMsgContext.getEnvelope().buildWithAttachments(); } catch (Exception e) { throw new AxisFault(e.getMessage()); }/* w ww .j a v a 2 s . c om*/ } MessageFormatter formatter = MessageProcessorSelector.getMessageFormatter(responseMsgContext); OMOutputFormat format = PassThroughTransportUtils.getOMOutputFormat(responseMsgContext); ByteArrayOutputStream out = new ByteArrayOutputStream(); formatter.writeTo(responseMsgContext, format, out, false); TreeSet<String> header = new TreeSet<String>(); header.add(String.valueOf(out.toByteArray().length)); headers.put(HTTP.CONTENT_LEN, header); } }
From source file:org.apache.synapse.transport.passthru.TargetRequest.java
public void start(NHttpClientConnection conn) throws IOException, HttpException { if (pipe != null) { TargetContext.get(conn).setWriter(pipe); }/*from w w w. jav a2s. c om*/ String path = fullUrl || (route.getProxyHost() != null && !route.isTunnelled()) ? url.toString() : url.getPath() + (url.getQuery() != null ? "?" + url.getQuery() : ""); long contentLength = -1; String contentLengthHeader = null; if (headers.get(HTTP.CONTENT_LEN) != null && headers.get(HTTP.CONTENT_LEN).size() > 0) { contentLengthHeader = headers.get(HTTP.CONTENT_LEN).first(); } if (contentLengthHeader != null) { contentLength = Integer.parseInt(contentLengthHeader); headers.remove(HTTP.CONTENT_LEN); } MessageContext requestMsgCtx = TargetContext.get(conn).getRequestMsgCtx(); if (requestMsgCtx.getProperty(PassThroughConstants.PASSTROUGH_MESSAGE_LENGTH) != null) { contentLength = (Long) requestMsgCtx.getProperty(PassThroughConstants.PASSTROUGH_MESSAGE_LENGTH); } //fix for POST_TO_URI if (requestMsgCtx.isPropertyTrue(NhttpConstants.POST_TO_URI)) { path = url.toString(); } //fix GET request empty body if ((("GET").equals(requestMsgCtx.getProperty(Constants.Configuration.HTTP_METHOD))) || (("DELETE").equals(requestMsgCtx.getProperty(Constants.Configuration.HTTP_METHOD)))) { hasEntityBody = false; MessageFormatter formatter = MessageProcessorSelector.getMessageFormatter(requestMsgCtx); OMOutputFormat format = PassThroughTransportUtils.getOMOutputFormat(requestMsgCtx); if (formatter != null && format != null) { URL _url = formatter.getTargetAddress(requestMsgCtx, format, url); if (_url != null && !_url.toString().isEmpty()) { if (requestMsgCtx.getProperty(NhttpConstants.POST_TO_URI) != null && Boolean.TRUE.toString() .equals(requestMsgCtx.getProperty(NhttpConstants.POST_TO_URI))) { path = _url.toString(); } else { path = _url.getPath() + ((_url.getQuery() != null && !_url.getQuery().isEmpty()) ? ("?" + _url.getQuery()) : ""); } } headers.remove(HTTP.CONTENT_TYPE); } } Object o = requestMsgCtx.getProperty(MessageContext.TRANSPORT_HEADERS); if (o != null && o instanceof TreeMap) { Map _headers = (Map) o; String trpContentType = (String) _headers.get(HTTP.CONTENT_TYPE); if (trpContentType != null && !trpContentType.equals("")) { if (!trpContentType.contains(PassThroughConstants.CONTENT_TYPE_MULTIPART_RELATED)) { addHeader(HTTP.CONTENT_TYPE, trpContentType); } } } if (hasEntityBody) { request = new BasicHttpEntityEnclosingRequest(method, path, version != null ? version : HttpVersion.HTTP_1_1); BasicHttpEntity entity = new BasicHttpEntity(); boolean forceContentLength = requestMsgCtx.isPropertyTrue(NhttpConstants.FORCE_HTTP_CONTENT_LENGTH); boolean forceContentLengthCopy = requestMsgCtx .isPropertyTrue(PassThroughConstants.COPY_CONTENT_LENGTH_FROM_INCOMING); if (forceContentLength) { entity.setChunked(false); if (forceContentLengthCopy && contentLength > 0) { entity.setContentLength(contentLength); } } else { if (contentLength != -1) { entity.setChunked(false); entity.setContentLength(contentLength); } else { entity.setChunked(chunk); } } ((BasicHttpEntityEnclosingRequest) request).setEntity(entity); } else { request = new BasicHttpRequest(method, path, version != null ? version : HttpVersion.HTTP_1_1); } Set<Map.Entry<String, TreeSet<String>>> entries = headers.entrySet(); for (Map.Entry<String, TreeSet<String>> entry : entries) { if (entry.getKey() != null) { Iterator<String> i = entry.getValue().iterator(); while (i.hasNext()) { request.addHeader(entry.getKey(), i.next()); } } } //setup wsa action.. if (request != null) { String soapAction = requestMsgCtx.getSoapAction(); if (soapAction == null) { soapAction = requestMsgCtx.getWSAAction(); } if (soapAction == null) { requestMsgCtx.getAxisOperation().getInputAction(); } if (requestMsgCtx.isSOAP11() && soapAction != null && soapAction.length() > 0) { Header existingHeader = request.getFirstHeader(HTTPConstants.HEADER_SOAP_ACTION); if (existingHeader != null) { request.removeHeader(existingHeader); } MessageFormatter messageFormatter = MessageFormatterDecoratorFactory .createMessageFormatterDecorator(requestMsgCtx); request.setHeader(HTTPConstants.HEADER_SOAP_ACTION, messageFormatter.formatSOAPAction(requestMsgCtx, null, soapAction)); //request.setHeader(HTTPConstants.USER_AGENT,"Synapse-PT-HttpComponents-NIO"); } } request.setParams(new DefaultedHttpParams(request.getParams(), targetConfiguration.getHttpParams())); //Chucking is not performed for request has "http 1.0" and "GET" http method if (!((request.getProtocolVersion().equals(HttpVersion.HTTP_1_0)) || (("GET").equals(requestMsgCtx.getProperty(Constants.Configuration.HTTP_METHOD))) || (("DELETE").equals(requestMsgCtx.getProperty(Constants.Configuration.HTTP_METHOD))))) { this.processChunking(conn, requestMsgCtx); } if (!keepAlive) { request.setHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE); } // Pre-process HTTP request conn.getContext().setAttribute(ExecutionContext.HTTP_CONNECTION, conn); conn.getContext().setAttribute(ExecutionContext.HTTP_TARGET_HOST, new HttpHost(url.getHost(), port)); conn.getContext().setAttribute(ExecutionContext.HTTP_REQUEST, request); // start the request targetConfiguration.getHttpProcessor().process(request, conn.getContext()); if (targetConfiguration.getProxyAuthenticator() != null && route.getProxyHost() != null && !route.isTunnelled()) { targetConfiguration.getProxyAuthenticator().authenticatePreemptively(request, conn.getContext()); } conn.submitRequest(request); if (hasEntityBody) { TargetContext.updateState(conn, ProtocolState.REQUEST_HEAD); } else { TargetContext.updateState(conn, ProtocolState.REQUEST_DONE); } }