List of usage examples for org.apache.http.client.fluent Request version
public Request version(final HttpVersion version)
From source file:com.jaspersoft.ireport.jasperserver.ws.http.JSSCommonsHTTPSender.java
/** * Extracts info from message context.//from w ww .j a v a 2 s.co m * * @param method * Post method * @param httpClient * The client used for posting * @param msgContext * the message context * @param tmpURL * the url to post to. * * @throws Exception */ private void addContextInfo(Request req, MessageContext msgContext, URL tmpURL) throws Exception { String v = msgContext.getStrProp(MessageContext.HTTP_TRANSPORT_VERSION); if (v != null && v.equals(HTTPConstants.HEADER_PROTOCOL_V10)) req.version(HttpVersion.HTTP_1_0); // optionally set a timeout for the request if (msgContext.getTimeout() != 0) { req.connectTimeout(msgContext.getTimeout()); req.socketTimeout(msgContext.getTimeout()); } // Get SOAPAction, default to "" String action = msgContext.useSOAPAction() ? msgContext.getSOAPActionURI() : ""; if (action == null) action = ""; Message msg = msgContext.getRequestMessage(); if (msg != null) req.addHeader(HTTPConstants.HEADER_CONTENT_TYPE, msg.getContentType(msgContext.getSOAPConstants())); req.addHeader(HTTPConstants.HEADER_SOAP_ACTION, "\"" + action + "\""); req.addHeader(HTTPConstants.HEADER_USER_AGENT, Messages.getMessage("axisUserAgent")); // add compression headers if needed if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) req.addHeader(HTTPConstants.HEADER_ACCEPT_ENCODING, HTTPConstants.COMPRESSION_GZIP); if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) req.addHeader(HTTPConstants.HEADER_CONTENT_ENCODING, HTTPConstants.COMPRESSION_GZIP); // Transfer MIME headers of SOAPMessage to HTTP headers. MimeHeaders mimeHeaders = msg.getMimeHeaders(); if (mimeHeaders != null) { for (Iterator<?> i = mimeHeaders.getAllHeaders(); i.hasNext();) { MimeHeader mimeHeader = (MimeHeader) i.next(); // HEADER_CONTENT_TYPE and HEADER_SOAP_ACTION are already set. // Let's not duplicate them. String headerName = mimeHeader.getName(); if (headerName.equals(HTTPConstants.HEADER_CONTENT_TYPE) || headerName.equals(HTTPConstants.HEADER_SOAP_ACTION)) continue; req.addHeader(mimeHeader.getName(), mimeHeader.getValue()); } } // process user defined headers for information. Hashtable<?, ?> userHeaderTable = (Hashtable<?, ?>) msgContext.getProperty(HTTPConstants.REQUEST_HEADERS); if (userHeaderTable != null) for (Map.Entry<?, ?> me : userHeaderTable.entrySet()) { Object keyObj = me.getKey(); if (null == keyObj) continue; String key = keyObj.toString().trim(); String value = me.getValue().toString().trim(); if (key.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT) && value.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT_100_Continue)) req.useExpectContinue(); else if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) { req.removeHeader(new BasicHeader("Transfer-Encoding", "chunked")); if (Boolean.parseBoolean(value)) ;// req.setHeader("Transfer-Encoding", "chunked"); } else req.addHeader(key, value); } }