Source:
protected HttpRequest getHttpRequest(NHttpClientConnection conn, String path) { long contentLength = getContentLength(conn); MessageContext requestMsgCtx = TargetContext.get(conn).getRequestMsgCtx(); HttpRequest request = new BasicHttpEntityEnclosingRequest(method, path, version != null ? version : HttpVersion.HTTP_1_1); BasicHttpEntity entity = new BasicHttpEntity(); ((BasicHttpEntityEnclosingRequest) request).setEntity(entity); 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 != -1) { if (log.isDebugEnabled()) { log.debug("Set ContentLength : " + contentLength); } entity.setContentLength(contentLength); } else if (!hasEntityBody) { if (log.isDebugEnabled()) { log.debug("Set BasicHttpRequest Object"); } request = new BasicHttpRequest(method, path, version != null ? version : HttpVersion.HTTP_1_1); } } else { if (contentLength != -1) { if (log.isDebugEnabled()) { log.debug("Set ContentLength : " + contentLength); } entity.setChunked(false); entity.setContentLength(contentLength); } else { if (hasEntityBody) { if (log.isDebugEnabled()) { log.debug("Set chunked : " + chunk); } entity.setChunked(chunk); } else { if (log.isDebugEnabled()) { log.debug("Set BasicHttpRequest Object"); } request = new BasicHttpRequest(method, path, version != null ? version : HttpVersion.HTTP_1_1); } } } Set<Map.Entry<String, LinkedHashSet<String>>> entries = headers.entrySet(); for (Map.Entry<String, LinkedHashSet<String>> entry : entries) { if (entry.getKey() != null) { Iterator<String> i = entry.getValue().iterator(); while(i.hasNext()) { request.addHeader(entry.getKey(), i.next()); } } } return request; }

Target:
protected HttpRequest getHttpRequest(NHttpClientConnection conn, String path) { long contentLength = getContentLength(conn); MessageContext requestMsgCtx = TargetContext.get(conn).getRequestMsgCtx(); HttpRequest request = new BasicHttpEntityEnclosingRequest(method, path, version != null ? version : HttpVersion.HTTP_1_1); BasicHttpEntity entity = new BasicHttpEntity(); ((BasicHttpEntityEnclosingRequest) request).setEntity(entity); 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 != -1) { if (log.isDebugEnabled()) { log.debug("Set ContentLength : " + contentLength); } entity.setContentLength(contentLength); } else if (!hasEntityBody) { if (log.isDebugEnabled()) { log.debug("Set BasicHttpRequest Object"); } request = new BasicHttpRequest(method, path, version != null ? version : HttpVersion.HTTP_1_1); } } else { if (contentLength != -1) { if (log.isDebugEnabled()) { log.debug("Set ContentLength : " + contentLength); } entity.setChunked(false); entity.setContentLength(contentLength); } else { if (hasEntityBody) { if (log.isDebugEnabled()) { log.debug("Set chunked : " + chunk); } entity.setChunked(chunk); } else { if (log.isDebugEnabled()) { log.debug("Set BasicHttpRequest Object"); } request = new BasicHttpRequest(method, path, version != null ? version : HttpVersion.HTTP_1_1); } } } Set<Map.Entry<String, LinkedHashSet<String>>> entries = headers.entrySet(); for (Map.Entry<String, LinkedHashSet<String>> entry : entries) { if (entry.getKey() != null) { Iterator<String> entryValues = entry.getValue().iterator(); while (entryValues.hasNext()) { request.addHeader(entry.getKey(), entryValues.next()); } } } return request; }