Example usage for javax.xml.soap MimeHeader getName

List of usage examples for javax.xml.soap MimeHeader getName

Introduction

In this page you can find the example usage for javax.xml.soap MimeHeader getName.

Prototype

public String getName() 

Source Link

Document

Returns the name of this MimeHeader object.

Usage

From source file:org.apache.manifoldcf.crawler.connectors.meridio.CommonsHTTPSender.java

/**
* Extracts info from message context./*from  w  w w .  j  av a 2  s.c om*/
*
* @param method Post or get method
* @param msgContext the message context
*/
private static boolean addContextInfo(HttpPost method, MessageContext msgContext) throws AxisFault {

    boolean httpChunkStream = false;

    // Get SOAPAction, default to ""
    String action = msgContext.useSOAPAction() ? msgContext.getSOAPActionURI() : "";

    if (action == null) {
        action = "";
    }

    Message msg = msgContext.getRequestMessage();

    if (msg != null) {

        // First, transfer MIME headers of SOAPMessage to HTTP headers.
        // Some of these might be overridden later.
        MimeHeaders mimeHeaders = msg.getMimeHeaders();
        if (mimeHeaders != null) {
            for (Iterator i = mimeHeaders.getAllHeaders(); i.hasNext();) {
                MimeHeader mimeHeader = (MimeHeader) i.next();
                method.addHeader(mimeHeader.getName(), mimeHeader.getValue());
            }
        }

        method.setHeader(new BasicHeader(HTTPConstants.HEADER_CONTENT_TYPE,
                msg.getContentType(msgContext.getSOAPConstants())));
    }

    method.setHeader(new BasicHeader("Accept", "*/*"));

    method.setHeader(new BasicHeader(HTTPConstants.HEADER_SOAP_ACTION, "\"" + action + "\""));
    method.setHeader(new BasicHeader(HTTPConstants.HEADER_USER_AGENT, Messages.getMessage("axisUserAgent")));

    // process user defined headers for information.
    Hashtable userHeaderTable = (Hashtable) msgContext.getProperty(HTTPConstants.REQUEST_HEADERS);

    if (userHeaderTable != null) {
        for (Iterator e = userHeaderTable.entrySet().iterator(); e.hasNext();) {
            Map.Entry me = (Map.Entry) e.next();
            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)) {
                HttpProtocolParams.setUseExpectContinue(method.getParams(), true);
            } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
                String val = me.getValue().toString();
                if (null != val) {
                    httpChunkStream = JavaUtils.isTrue(val);
                }
            } else {
                method.addHeader(key, value);
            }
        }
    }

    return httpChunkStream;
}

From source file:org.apache.manifoldcf.connectorcommon.common.CommonsHTTPSender.java

/**
* Extracts info from message context./*from w w w .j  ava 2 s  . c om*/
*
* @param method Post or get method
* @param msgContext the message context
*/
private static boolean addContextInfo(HttpPost method, MessageContext msgContext) throws AxisFault {

    boolean httpChunkStream = false;

    // Get SOAPAction, default to ""
    String action = msgContext.useSOAPAction() ? msgContext.getSOAPActionURI() : "";

    if (action == null) {
        action = "";
    }

    Message msg = msgContext.getRequestMessage();

    if (msg != null) {

        // First, transfer MIME headers of SOAPMessage to HTTP headers.
        // Some of these might be overridden later.
        MimeHeaders mimeHeaders = msg.getMimeHeaders();
        if (mimeHeaders != null) {
            for (Iterator i = mimeHeaders.getAllHeaders(); i.hasNext();) {
                MimeHeader mimeHeader = (MimeHeader) i.next();
                method.addHeader(mimeHeader.getName(), mimeHeader.getValue());
            }
        }

        method.setHeader(new BasicHeader(HTTPConstants.HEADER_CONTENT_TYPE,
                msg.getContentType(msgContext.getSOAPConstants())));
    }

    method.setHeader(new BasicHeader("Accept", "*/*"));

    method.setHeader(new BasicHeader(HTTPConstants.HEADER_SOAP_ACTION, "\"" + action + "\""));
    method.setHeader(new BasicHeader(HTTPConstants.HEADER_USER_AGENT, Messages.getMessage("axisUserAgent")));

    // process user defined headers for information.
    Hashtable userHeaderTable = (Hashtable) msgContext.getProperty(HTTPConstants.REQUEST_HEADERS);

    if (userHeaderTable != null) {
        for (Iterator e = userHeaderTable.entrySet().iterator(); e.hasNext();) {
            Map.Entry me = (Map.Entry) e.next();
            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)) {
            //  HttpProtocolParams.setUseExpectContinue(method.getParams(),true);
            //} else 
            if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
                String val = me.getValue().toString();
                if (null != val) {
                    httpChunkStream = JavaUtils.isTrue(val);
                }
            } else {
                method.addHeader(key, value);
            }
        }
    }

    return httpChunkStream;
}

From source file:com.jaspersoft.ireport.jasperserver.ws.http.JSSCommonsHTTPSender.java

/**
 * Extracts info from message context./*from  w  w  w  .ja  v a 2  s. c  o 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);
        }
}

From source file:org.dcache.srm.client.HttpClientSender.java

/**
 * Creates a HttpRequest encoding a particular SOAP call.
 *
 * Called once per SOAP call.//from   www  . ja  v  a2  s  .co m
 */
protected HttpUriRequest createHttpRequest(MessageContext msgContext, URI url) throws AxisFault {
    boolean posting = true;
    // If we're SOAP 1.2, allow the web method to be set from the
    // MessageContext.
    if (msgContext.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS) {
        String webMethod = msgContext.getStrProp(SOAP12Constants.PROP_WEBMETHOD);
        if (webMethod != null) {
            posting = webMethod.equals(HTTPConstants.HEADER_POST);
        }
    }

    HttpRequestBase request = posting ? new HttpPost(url) : new HttpGet(url);

    // Get SOAPAction, default to ""
    String action = msgContext.useSOAPAction() ? msgContext.getSOAPActionURI() : "";
    if (action == null) {
        action = "";
    }

    Message msg = msgContext.getRequestMessage();
    request.addHeader(HTTPConstants.HEADER_CONTENT_TYPE, msg.getContentType(msgContext.getSOAPConstants()));
    request.addHeader(HTTPConstants.HEADER_SOAP_ACTION, "\"" + action + "\"");

    String httpVersion = msgContext.getStrProp(MessageContext.HTTP_TRANSPORT_VERSION);
    if (httpVersion != null && httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_V10)) {
        request.setProtocolVersion(HttpVersion.HTTP_1_0);
    }

    // Transfer MIME headers of SOAPMessage to HTTP headers.
    MimeHeaders mimeHeaders = msg.getMimeHeaders();
    if (mimeHeaders != null) {
        Iterator i = mimeHeaders.getAllHeaders();
        while (i.hasNext()) {
            MimeHeader mimeHeader = (MimeHeader) i.next();
            // HEADER_CONTENT_TYPE and HEADER_SOAP_ACTION are already set.
            // Let's not duplicate them.
            String name = mimeHeader.getName();
            if (!name.equals(HTTPConstants.HEADER_CONTENT_TYPE)
                    && !name.equals(HTTPConstants.HEADER_SOAP_ACTION)) {
                request.addHeader(name, mimeHeader.getValue());
            }
        }
    }

    boolean isChunked = false;
    boolean isExpectContinueEnabled = false;
    Map<?, ?> userHeaderTable = (Map) msgContext.getProperty(HTTPConstants.REQUEST_HEADERS);
    if (userHeaderTable != null) {
        for (Map.Entry<?, ?> me : userHeaderTable.entrySet()) {
            Object keyObj = me.getKey();
            if (keyObj != null) {
                String key = keyObj.toString().trim();
                String value = me.getValue().toString().trim();
                if (key.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT)) {
                    isExpectContinueEnabled = value.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT_100_Continue);
                } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
                    isChunked = JavaUtils.isTrue(value);
                } else {
                    request.addHeader(key, value);
                }
            }
        }
    }

    RequestConfig.Builder config = RequestConfig.custom();
    // optionally set a timeout for the request
    if (msgContext.getTimeout() != 0) {
        /* ISSUE: these are not the same, but MessageContext has only one definition of timeout */
        config.setSocketTimeout(msgContext.getTimeout()).setConnectTimeout(msgContext.getTimeout());
    } else if (clientProperties.getConnectionPoolTimeout() != 0) {
        config.setConnectTimeout(clientProperties.getConnectionPoolTimeout());
    }
    config.setContentCompressionEnabled(msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP));
    config.setExpectContinueEnabled(isExpectContinueEnabled);
    request.setConfig(config.build());

    if (request instanceof HttpPost) {
        HttpEntity requestEntity = new MessageEntity(request, msgContext.getRequestMessage(), isChunked);
        if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
            requestEntity = new GzipCompressingEntity(requestEntity);
        }
        ((HttpPost) request).setEntity(requestEntity);
    }

    return request;
}

From source file:fi.laverca.util.CommonsHTTPSender.java

/**
 * Extracts info from message context./*from  ww  w  .  j av  a 2s  .  c  om*/
 *
 * @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 if any error occurred
 */
private void addContextInfo(final HttpPost method, final HttpClient httpClient, final MessageContext msgContext,
        final URL tmpURL) throws Exception {
    HttpParams params = method.getParams();

    if (msgContext.getTimeout() != 0) {
        // optionally set a timeout for response waits
        HttpConnectionParams.setSoTimeout(params, msgContext.getTimeout());
    }

    // Always set the 30 second timeout on establishing the connection
    HttpConnectionParams.setConnectionTimeout(params, connectionTimeout);

    Message msg = msgContext.getRequestMessage();
    if (msg != null) {
        method.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, msg.getContentType(msgContext.getSOAPConstants()));
    }

    if (msgContext.useSOAPAction()) {
        // define SOAPAction header
        String action = msgContext.getSOAPActionURI();
        if (action != null && !"".equals(action))
            method.setHeader(HTTPConstants.HEADER_SOAP_ACTION, "\"" + action + "\"");
    }

    String userID = msgContext.getUsername();
    String passwd = msgContext.getPassword();

    // if UserID is not part of the context, but is in the URL, use
    // the one in the URL.
    if ((userID == null) && (tmpURL.getUserInfo() != null)) {
        String info = tmpURL.getUserInfo();
        int sep = info.indexOf(':');

        if ((sep >= 0) && (sep + 1 < info.length())) {
            userID = info.substring(0, sep);
            passwd = info.substring(sep + 1);
        } else {
            userID = info;
        }
    }
    if (userID != null) {
        Credentials proxyCred = new UsernamePasswordCredentials(userID, passwd);
        // if the username is in the form "user\domain"
        // then use NTCredentials instead.
        int domainIndex = userID.indexOf("\\");
        if (domainIndex > 0) {
            String domain = userID.substring(0, domainIndex);
            if (userID.length() > domainIndex + 1) {
                String user = userID.substring(domainIndex + 1);
                proxyCred = new NTCredentials(user, passwd, NetworkUtils.getLocalHostname(), domain);
            }
        }
        ((DefaultHttpClient) httpClient).getCredentialsProvider().setCredentials(AuthScope.ANY, proxyCred);
    }

    // add compression headers if needed
    if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) {
        method.addHeader(HTTPConstants.HEADER_ACCEPT_ENCODING, HTTPConstants.COMPRESSION_GZIP);
    }
    if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
        method.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;
            }
            method.addHeader(mimeHeader.getName(), mimeHeader.getValue());
        }
    }

    // process user defined headers for information.
    Hashtable<?, ?> userHeaderTable = (Hashtable<?, ?>) msgContext.getProperty(HTTPConstants.REQUEST_HEADERS);

    if (userHeaderTable != null) {
        for (Iterator<?> e = userHeaderTable.entrySet().iterator(); e.hasNext();) {
            Map.Entry<?, ?> me = (Map.Entry<?, ?>) e.next();
            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)) {
                HttpProtocolParams.setUseExpectContinue(params, true);
            } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
                String val = me.getValue().toString();
                if (null != val) {
                    httpChunkStream = JavaUtils.isTrue(val);
                }
            } else {
                method.addHeader(key, value);
            }
        }
    }
}

From source file:lucee.runtime.net.rpc.server.RPCServer.java

/**
 * Process a POST to the servlet by handing it off to the Axis Engine.
 * Here is where SOAP messages are received
 * @param req posted request//w w  w  .  jav  a2s . com
 * @param res respose
 * @throws ServletException trouble
 * @throws IOException different trouble
 */
public void doPost(HttpServletRequest req, HttpServletResponse res, Component component)
        throws ServletException, IOException {
    long t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0;
    String soapAction = null;
    MessageContext msgContext = null;

    Message rspMsg = null;
    String contentType = null;
    InputStream is = null;
    try {
        AxisEngine engine = getEngine();

        if (engine == null) {
            // !!! should return a SOAP fault...
            ServletException se = new ServletException(Messages.getMessage("noEngine00"));
            log.debug("No Engine!", se);
            throw se;
        }

        res.setBufferSize(1024 * 8); // provide performance boost.

        /** get message context w/ various properties set
         */
        msgContext = createMessageContext(engine, req, res, component);
        ComponentController.set(msgContext);

        // ? OK to move this to 'getMessageContext',
        // ? where it would also be picked up for 'doGet()' ?
        if (securityProvider != null) {
            if (isDebug) {
                log.debug("securityProvider:" + securityProvider);
            }
            msgContext.setProperty(MessageContext.SECURITY_PROVIDER, securityProvider);
        }

        is = req.getInputStream();
        Message requestMsg = new Message(is, false, req.getHeader(HTTPConstants.HEADER_CONTENT_TYPE),
                req.getHeader(HTTPConstants.HEADER_CONTENT_LOCATION));
        // Transfer HTTP headers to MIME headers for request message.
        MimeHeaders requestMimeHeaders = requestMsg.getMimeHeaders();
        for (Enumeration e = req.getHeaderNames(); e.hasMoreElements();) {
            String headerName = (String) e.nextElement();
            for (Enumeration f = req.getHeaders(headerName); f.hasMoreElements();) {
                String headerValue = (String) f.nextElement();
                requestMimeHeaders.addHeader(headerName, headerValue);
            }
        }

        if (isDebug) {
            log.debug("Request Message:" + requestMsg);

            /* Set the request(incoming) message field in the context */
            /**********************************************************/
        }
        msgContext.setRequestMessage(requestMsg);
        String url = HttpUtils.getRequestURL(req).toString().toLowerCase();
        msgContext.setProperty(MessageContext.TRANS_URL, url);
        // put character encoding of request to message context
        // in order to reuse it during the whole process.

        try {
            String reqEnc = (String) requestMsg.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
            if (reqEnc != null)
                msgContext.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, reqEnc);
        } catch (SOAPException e1) {
        }

        try {
            /**
             * Save the SOAPAction header in the MessageContext bag.
             * This will be used to tell the Axis Engine which service
             * is being invoked.  This will save us the trouble of
             * having to parse the Request message - although we will
             * need to double-check later on that the SOAPAction header
             * does in fact match the URI in the body.
             */
            // (is this last stmt true??? (I don't think so - Glen))
            /********************************************************/
            soapAction = getSoapAction(req);
            if (soapAction != null) {
                msgContext.setUseSOAPAction(true);
                msgContext.setSOAPActionURI(soapAction);
            }

            // Create a Session wrapper for the HTTP session.
            // These can/should be pooled at some point.
            // (Sam is Watching! :-)
            msgContext.setSession(new AxisHttpSession(req));

            if (tlog.isDebugEnabled()) {
                t1 = System.currentTimeMillis();
            }
            /* Invoke the Axis engine... */
            /*****************************/
            if (isDebug) {
                log.debug("Invoking Axis Engine.");
                //here we run the message by the engine
            }
            //msgContext.setProperty("disablePrettyXML", "false");
            engine.invoke(msgContext);
            if (isDebug) {
                log.debug("Return from Axis Engine.");
            }
            if (tlog.isDebugEnabled()) {
                t2 = System.currentTimeMillis();
            }

            rspMsg = msgContext.getResponseMessage();

            // We used to throw exceptions on null response messages.
            // They are actually OK in certain situations (asynchronous
            // services), so fall through here and return an ACCEPTED
            // status code below.  Might want to install a configurable
            // error check for this later.
        } catch (AxisFault fault) {

            //log and sanitize
            processAxisFault(fault);
            configureResponseFromAxisFault(res, fault);
            rspMsg = msgContext.getResponseMessage();
            if (rspMsg == null) {
                rspMsg = new Message(fault);
                ((org.apache.axis.SOAPPart) rspMsg.getSOAPPart()).getMessage().setMessageContext(msgContext);
            }
        } catch (Throwable t) {
            if (t instanceof InvocationTargetException)
                t = ((InvocationTargetException) t).getTargetException();
            // Exception
            if (t instanceof Exception) {
                Exception e = (Exception) t;
                //other exceptions are internal trouble
                rspMsg = msgContext.getResponseMessage();
                res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                rspMsg = convertExceptionToAxisFault(e, rspMsg);
                ((org.apache.axis.SOAPPart) rspMsg.getSOAPPart()).getMessage().setMessageContext(msgContext);

            }
            // throwable
            else {
                logException(t);
                //other exceptions are internal trouble
                rspMsg = msgContext.getResponseMessage();
                res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                rspMsg = new Message(new AxisFault(t.toString(), t));
                ((org.apache.axis.SOAPPart) rspMsg.getSOAPPart()).getMessage().setMessageContext(msgContext);
            }
        }
    } catch (AxisFault fault) {

        processAxisFault(fault);
        configureResponseFromAxisFault(res, fault);
        rspMsg = msgContext.getResponseMessage();
        if (rspMsg == null) {
            rspMsg = new Message(fault);
            ((org.apache.axis.SOAPPart) rspMsg.getSOAPPart()).getMessage().setMessageContext(msgContext);
        }
    } finally {
        IOUtil.closeEL(is);
    }

    if (tlog.isDebugEnabled()) {
        t3 = System.currentTimeMillis();
    }

    // Send response back along the wire... 
    if (rspMsg != null) {

        // Transfer MIME headers to HTTP headers for response message.
        MimeHeaders responseMimeHeaders = rspMsg.getMimeHeaders();
        for (Iterator i = responseMimeHeaders.getAllHeaders(); i.hasNext();) {
            MimeHeader responseMimeHeader = (MimeHeader) i.next();
            res.addHeader(responseMimeHeader.getName(), responseMimeHeader.getValue());
        }
        // synchronize the character encoding of request and response
        String responseEncoding = (String) msgContext.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
        if (responseEncoding != null) {
            try {
                rspMsg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, responseEncoding);
            } catch (SOAPException e) {
            }
        }

        //determine content type from message response
        contentType = rspMsg.getContentType(msgContext.getSOAPConstants());
        if (isDebug)
            log.debug("Returned Content-Type:" + contentType);

        // write result to response stream
        try {
            res.setContentType(contentType);
            rspMsg.writeTo(res.getOutputStream());
        } catch (SOAPException e) {
            logException(e);
        }

        if (!res.isCommitted())
            res.flushBuffer(); // Force it right now.
    } else {
        // No content, so just indicate accepted
        res.setStatus(202);
    }

    if (isDebug) {
        log.debug("Response sent.");
        log.debug("Exit: doPost()");
    }
    if (tlog.isDebugEnabled()) {
        t4 = System.currentTimeMillis();
        tlog.debug("axisServlet.doPost: " + soapAction + " pre=" + (t1 - t0) + " invoke=" + (t2 - t1) + " post="
                + (t3 - t2) + " send=" + (t4 - t3) + " " + msgContext.getTargetService() + "."
                + ((msgContext.getOperation() == null) ? "" : msgContext.getOperation().getName()));
    }

}

From source file:com.betfair.testing.utils.cougar.helpers.CougarHelpers.java

private void extractHeaderDataSOAP(SOAPMessage response, HttpResponseBean responseBean) throws SOAPException {
    //extract MimeHeaders
    MimeHeaders mime = response.getMimeHeaders();
    Iterator<MimeHeader> iter = mime.getAllHeaders();

    while (iter.hasNext()) {
        MimeHeader mimeH = iter.next();
        responseBean.addEntryToResponseHeaders(mimeH.getName(), mimeH.getValue());

    }//from  w  w w  .ja  v  a  2s  .  com

    //extract SOAPHeaders from the envelope and a them to the mimeHeaders
    if (response.getSOAPHeader() != null) {
        javax.xml.soap.SOAPHeader header = response.getSOAPHeader();

        NodeList nodes = header.getChildNodes();

        for (int x = 0; x < nodes.getLength(); x++) {
            //if the header entry contains child nodes - write them with the node names
            if (nodes.item(x).hasChildNodes()) {
                NodeList childnodes = nodes.item(x).getChildNodes();
                for (int y = 0; y < childnodes.getLength(); y++) {
                    responseBean.addEntryToResponseHeaders(nodes.item(x).getLocalName(),
                            childnodes.item(y).getLocalName() + ":" + childnodes.item(y).getTextContent());
                }
            } else {
                responseBean.addEntryToResponseHeaders(nodes.item(x).getLocalName(),
                        nodes.item(x).getTextContent());
            }
        }
    }
}

From source file:com.hp.it.spf.wsrp.axis.transport.http.HTTPSender.java

/**
 * Send the soap request message to the server
 *
 * @param msgContext message context/*  w w  w  .ja v  a2 s.  c o  m*/
 * @param targetURL url to connect to
 * @param otherHeaders other headers if any
 * @param useFullURL flag to indicate if the whole url needs to be sent
 *
 * @throws IOException
 */
private InputStream writeToSocket(SocketHolder sockHolder, MessageContext msgContext, URL targetURL,
        StringBuffer otherHeaders, int timeout, BooleanHolder useFullURL) throws Exception {

    String userID = msgContext.getUsername();
    String passwd = msgContext.getPassword();

    // Get SOAPAction, default to ""
    String action = msgContext.useSOAPAction() ? msgContext.getSOAPActionURI() : "";

    if (action == null) {
        action = "";
    }

    // if UserID is not part of the context, but is in the URL, use
    // the one in the URL.
    if ((userID == null) && (targetURL.getUserInfo() != null)) {
        String info = targetURL.getUserInfo();
        int sep = info.indexOf(':');

        if ((sep >= 0) && (sep + 1 < info.length())) {
            userID = info.substring(0, sep);
            passwd = info.substring(sep + 1);
        } else {
            userID = info;
        }
    }
    if (userID != null) {
        StringBuffer tmpBuf = new StringBuffer();

        tmpBuf.append(userID).append(":").append((passwd == null) ? "" : passwd);
        otherHeaders.append(HTTPConstants.HEADER_AUTHORIZATION).append(": Basic ")
                .append(Base64.encode(tmpBuf.toString().getBytes())).append("\r\n");
    }

    // don't forget the cookies!
    // mmm... cookies
    if (msgContext.getMaintainSession()) {
        fillHeaders(msgContext, HTTPConstants.HEADER_COOKIE, otherHeaders);
        fillHeaders(msgContext, HTTPConstants.HEADER_COOKIE2, otherHeaders);
    }

    StringBuffer header2 = new StringBuffer();

    String webMethod = null;
    boolean posting = true;

    Message reqMessage = msgContext.getRequestMessage();

    boolean http10 = true; //True if this is to use HTTP 1.0 / false HTTP 1.1
    boolean httpChunkStream = false; //Use HTTP chunking or not.
    boolean httpContinueExpected = false; //Under HTTP 1.1 if false you *MAY* need to wait for a 100 rc,
                                          //  if true the server MUST reply with 100 continue.
    String httpConnection = null;

    String httpver = msgContext.getStrProp(MessageContext.HTTP_TRANSPORT_VERSION);
    if (null == httpver) {
        httpver = HTTPConstants.HEADER_PROTOCOL_V10;
    }
    httpver = httpver.trim();
    if (httpver.equals(HTTPConstants.HEADER_PROTOCOL_V11)) {
        http10 = false;
    }

    //process user defined headers for information.
    Hashtable userHeaderTable = (Hashtable) msgContext.getProperty(HTTPConstants.REQUEST_HEADERS);

    if (userHeaderTable != null) {
        if (null == otherHeaders) {
            otherHeaders = new StringBuffer(1024);
        }

        for (java.util.Iterator e = userHeaderTable.entrySet().iterator(); e.hasNext();) {

            java.util.Map.Entry me = (java.util.Map.Entry) e.next();
            Object keyObj = me.getKey();
            if (null == keyObj)
                continue;
            String key = keyObj.toString().trim();

            if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING)) {
                if (!http10) {
                    String val = me.getValue().toString();
                    if (null != val
                            && val.trim().equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED))
                        httpChunkStream = true;
                }
            } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_CONNECTION)) {
                if (!http10) {
                    String val = me.getValue().toString();
                    if (val.trim().equalsIgnoreCase(HTTPConstants.HEADER_CONNECTION_CLOSE))
                        httpConnection = HTTPConstants.HEADER_CONNECTION_CLOSE;
                }
                //HTTP 1.0 will always close.
                //HTTP 1.1 will use persistent. //no need to specify
            } else {
                if (!http10 && key.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT)) {
                    String val = me.getValue().toString();
                    if (null != val && val.trim().equalsIgnoreCase(HTTPConstants.HEADER_EXPECT_100_Continue))
                        httpContinueExpected = true;
                }

                otherHeaders.append(key).append(": ").append(me.getValue()).append("\r\n");
            }
        }
    }

    if (!http10) {
        //Force close for now.
        //TODO HTTP/1.1
        httpConnection = HTTPConstants.HEADER_CONNECTION_CLOSE;
    }

    header2.append(" ");
    header2.append(http10 ? HTTPConstants.HEADER_PROTOCOL_10 : HTTPConstants.HEADER_PROTOCOL_11).append("\r\n");
    MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();

    if (posting) {
        String contentType;
        final String[] header = mimeHeaders.getHeader(HTTPConstants.HEADER_CONTENT_TYPE);
        if (header != null && header.length > 0) {
            contentType = mimeHeaders.getHeader(HTTPConstants.HEADER_CONTENT_TYPE)[0];
        } else {
            contentType = reqMessage.getContentType(msgContext.getSOAPConstants());
        }

        //fix for AXIS-2027
        if (contentType == null || contentType.equals("")) {
            throw new Exception(Messages.getMessage("missingContentType"));
        }
        header2.append(HTTPConstants.HEADER_CONTENT_TYPE).append(": ").append(contentType).append("\r\n");
    }

    //Get host and port
    String host = targetURL.getHost();
    int port = targetURL.getPort();

    header2.append(ACCEPT_HEADERS).append(HTTPConstants.HEADER_HOST) //used for virtual connections
            .append(": ").append(host).append((port == -1) ? ("") : (":" + port)).append("\r\n")
            .append(CACHE_HEADERS).append(HTTPConstants.HEADER_SOAP_ACTION) //The SOAP action.
            .append(": \"").append(action).append("\"\r\n");

    if (posting) {
        if (!httpChunkStream) {
            //Content length MUST be sent on HTTP 1.0 requests.
            header2.append(HTTPConstants.HEADER_CONTENT_LENGTH).append(": ")
                    .append(reqMessage.getContentLength()).append("\r\n");
        } else {
            //Do http chunking.
            header2.append(CHUNKED_HEADER);
        }
    }

    // Transfer MIME headers of SOAPMessage to HTTP headers.
    if (mimeHeaders != null) {
        for (Iterator i = mimeHeaders.getAllHeaders(); i.hasNext();) {
            MimeHeader mimeHeader = (MimeHeader) i.next();
            String headerName = mimeHeader.getName();
            if (headerName.equals(HTTPConstants.HEADER_CONTENT_TYPE)
                    || headerName.equals(HTTPConstants.HEADER_SOAP_ACTION)) {
                continue;
            }
            header2.append(mimeHeader.getName()).append(": ").append(mimeHeader.getValue()).append("\r\n");
        }
    }

    if (null != httpConnection) {
        header2.append(HTTPConstants.HEADER_CONNECTION);
        header2.append(": ");
        header2.append(httpConnection);
        header2.append("\r\n");
    }

    getSocket(sockHolder, msgContext, targetURL.getProtocol(), host, port, timeout, otherHeaders, useFullURL);

    if (null != otherHeaders) {
        //Add other headers to the end.
        //for pre java1.4 support, we have to turn the string buffer argument into
        //a string before appending.
        header2.append(otherHeaders.toString());
    }

    header2.append("\r\n"); //The empty line to start the BODY.

    StringBuffer header = new StringBuffer();

    // If we're SOAP 1.2, allow the web method to be set from the
    // MessageContext.
    if (msgContext.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS) {
        webMethod = msgContext.getStrProp(SOAP12Constants.PROP_WEBMETHOD);
    }
    if (webMethod == null) {
        webMethod = HTTPConstants.HEADER_POST;
    } else {
        posting = webMethod.equals(HTTPConstants.HEADER_POST);
    }

    header.append(webMethod).append(" ");
    if (useFullURL.value) {
        header.append(targetURL.toExternalForm());
    } else {
        header.append((((targetURL.getFile() == null) || targetURL.getFile().equals("")) ? "/"
                : targetURL.getFile()));
    }
    header.append(header2.toString());

    OutputStream out = sockHolder.getSocket().getOutputStream();

    if (!posting) {
        out.write(header.toString().getBytes(HTTPConstants.HEADER_DEFAULT_CHAR_ENCODING));
        out.flush();
        return null;
    }

    InputStream inp = null;

    if (httpChunkStream || httpContinueExpected) {
        out.write(header.toString().getBytes(HTTPConstants.HEADER_DEFAULT_CHAR_ENCODING));
    }

    if (httpContinueExpected) { //We need to get a reply from the server as to whether
        // it wants us send anything more.
        out.flush();
        Hashtable cheaders = new Hashtable();
        inp = readHeadersFromSocket(sockHolder, msgContext, null, cheaders);
        int returnCode = -1;
        Integer Irc = (Integer) msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE);
        if (null != Irc) {
            returnCode = Irc.intValue();
        }
        if (100 == returnCode) { // got 100 we may continue.
            //Need todo a little msgContext house keeping....
            msgContext.removeProperty(HTTPConstants.MC_HTTP_STATUS_CODE);
            msgContext.removeProperty(HTTPConstants.MC_HTTP_STATUS_MESSAGE);
        } else { //If no 100 Continue then we must not send anything!
            String statusMessage = (String) msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_MESSAGE);

            AxisFault fault = new AxisFault("HTTP", "(" + returnCode + ")" + statusMessage, null, null);

            fault.setFaultDetailString(Messages.getMessage("return01", "" + returnCode, ""));
            throw fault;
        }
    }
    ByteArrayOutputStream baos = null;
    if (log.isDebugEnabled()) {
        log.debug(Messages.getMessage("xmlSent00"));
        log.debug("---------------------------------------------------");
        baos = new ByteArrayOutputStream();
    }
    if (httpChunkStream) {
        ChunkedOutputStream chunkedOutputStream = new ChunkedOutputStream(out);
        out = new BufferedOutputStream(chunkedOutputStream, Constants.HTTP_TXR_BUFFER_SIZE);
        try {
            if (baos != null) {
                out = new TeeOutputStream(out, baos);
            }
            reqMessage.writeTo(out);
        } catch (SOAPException e) {
            log.error(Messages.getMessage("exception00"), e);
        }
        out.flush();
        chunkedOutputStream.eos();
    } else {
        out = new BufferedOutputStream(out, Constants.HTTP_TXR_BUFFER_SIZE);
        try {
            if (!httpContinueExpected) {
                out.write(header.toString().getBytes(HTTPConstants.HEADER_DEFAULT_CHAR_ENCODING));
            }
            if (baos != null) {
                out = new TeeOutputStream(out, baos);
            }
            reqMessage.writeTo(out);
        } catch (SOAPException e) {
            log.error(Messages.getMessage("exception00"), e);
        }
        // Flush ONLY once.
        out.flush();
    }
    if (log.isDebugEnabled()) {
        log.debug(header + new String(baos.toByteArray()));
    }

    return inp;
}

From source file:com.polarion.alm.ws.client.internal.connection.CommonsHTTPSender.java

/**
 * Extracts info from message context.//ww  w .  java  2  s .c  o 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(HttpMethodBase method, HttpClient httpClient, MessageContext msgContext, URL tmpURL)
        throws Exception {

    // optionally set a timeout for the request
    if (msgContext.getTimeout() != 0) {
        /*
         * ISSUE: these are not the same, but MessageContext has only one
         * definition of timeout
         */
        // SO_TIMEOUT -- timeout for blocking reads
        httpClient.getHttpConnectionManager().getParams().setSoTimeout(msgContext.getTimeout());
        // timeout for initial connection
        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(msgContext.getTimeout());
    }

    // Get SOAPAction, default to ""
    String action = msgContext.useSOAPAction() ? msgContext.getSOAPActionURI() : "";

    if (action == null) {
        action = "";
    }

    Message msg = msgContext.getRequestMessage();
    if (msg != null) {
        method.setRequestHeader(new Header(HTTPConstants.HEADER_CONTENT_TYPE,
                msg.getContentType(msgContext.getSOAPConstants())));
    }
    method.setRequestHeader(new Header(HTTPConstants.HEADER_SOAP_ACTION, "\"" + action + "\""));
    method.setRequestHeader(new Header(HTTPConstants.HEADER_USER_AGENT, Messages.getMessage("axisUserAgent")));
    String userID = msgContext.getUsername();
    String passwd = msgContext.getPassword();

    // if UserID is not part of the context, but is in the URL, use
    // the one in the URL.
    if ((userID == null) && (tmpURL.getUserInfo() != null)) {
        String info = tmpURL.getUserInfo();
        int sep = info.indexOf(':');

        if ((sep >= 0) && (sep + 1 < info.length())) {
            userID = info.substring(0, sep);
            passwd = info.substring(sep + 1);
        } else {
            userID = info;
        }
    }
    if (userID != null) {
        Credentials proxyCred = new UsernamePasswordCredentials(userID, passwd);
        // if the username is in the form "user\domain"
        // then use NTCredentials instead.
        int domainIndex = userID.indexOf("\\");
        if (domainIndex > 0) {
            String domain = userID.substring(0, domainIndex);
            if (userID.length() > domainIndex + 1) {
                String user = userID.substring(domainIndex + 1);
                proxyCred = new NTCredentials(user, passwd, NetworkUtils.getLocalHostname(), domain);
            }
        }
        httpClient.getState().setCredentials(AuthScope.ANY, proxyCred);
    }

    // add compression headers if needed
    if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) {
        method.addRequestHeader(HTTPConstants.HEADER_ACCEPT_ENCODING, HTTPConstants.COMPRESSION_GZIP);
    }
    if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
        method.addRequestHeader(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;
            }
            method.addRequestHeader(mimeHeader.getName(), mimeHeader.getValue());
        }
    }

    // process user defined headers for information.
    Hashtable userHeaderTable = (Hashtable) msgContext.getProperty(HTTPConstants.REQUEST_HEADERS);

    if (userHeaderTable != null) {
        for (Iterator e = userHeaderTable.entrySet().iterator(); e.hasNext();) {
            Map.Entry me = (Map.Entry) e.next();
            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)) {
                method.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, true);
            } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
                String val = me.getValue().toString();
                if (null != val) {
                    httpChunkStream = JavaUtils.isTrue(val);
                }
            } else {
                method.addRequestHeader(key, value);
            }
        }
    }
}

From source file:com.jaspersoft.ireport.jasperserver.ws.CommonsHTTPSender.java

/**
 * Extracts info from message context./*from   w w w .j  a  v a2 s  .  c  o  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(HttpMethodBase method, HttpClient httpClient, MessageContext msgContext, URL tmpURL)
        throws Exception {

    // optionally set a timeout for the request
    if (msgContext.getTimeout() != 0) {
        /* ISSUE: these are not the same, but MessageContext has only one
              definition of timeout */
        // SO_TIMEOUT -- timeout for blocking reads
        httpClient.getHttpConnectionManager().getParams().setSoTimeout(msgContext.getTimeout());
        // timeout for initial connection
        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(msgContext.getTimeout());
    }

    // Get SOAPAction, default to ""
    String action = msgContext.useSOAPAction() ? msgContext.getSOAPActionURI() : "";

    if (action == null) {
        action = "";
    }

    Message msg = msgContext.getRequestMessage();
    if (msg != null) {
        method.setRequestHeader(new Header(HTTPConstants.HEADER_CONTENT_TYPE,
                msg.getContentType(msgContext.getSOAPConstants())));
    }
    method.setRequestHeader(new Header(HTTPConstants.HEADER_SOAP_ACTION, "\"" + action + "\""));
    method.setRequestHeader(new Header(HTTPConstants.HEADER_USER_AGENT, Messages.getMessage("axisUserAgent")));
    String userID = msgContext.getUsername();
    String passwd = msgContext.getPassword();

    // if UserID is not part of the context, but is in the URL, use
    // the one in the URL.
    if ((userID == null) && (tmpURL.getUserInfo() != null)) {
        String info = tmpURL.getUserInfo();
        int sep = info.indexOf(':');

        if ((sep >= 0) && (sep + 1 < info.length())) {
            userID = info.substring(0, sep);
            passwd = info.substring(sep + 1);
        } else {
            userID = info;
        }
    }
    if (userID != null) {
        Credentials proxyCred = new UsernamePasswordCredentials(userID, passwd);
        // if the username is in the form "user\domain"
        // then use NTCredentials instead.
        int domainIndex = userID.indexOf("\\");
        if (domainIndex > 0) {
            String domain = userID.substring(0, domainIndex);
            if (userID.length() > domainIndex + 1) {
                String user = userID.substring(domainIndex + 1);
                proxyCred = new NTCredentials(user, passwd, NetworkUtils.getLocalHostname(), domain);
            }
        }
        httpClient.getState().setCredentials(AuthScope.ANY, proxyCred);
    }

    // add compression headers if needed
    if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) {
        method.addRequestHeader(HTTPConstants.HEADER_ACCEPT_ENCODING, HTTPConstants.COMPRESSION_GZIP);
    }
    if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
        method.addRequestHeader(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;
            }
            method.addRequestHeader(mimeHeader.getName(), mimeHeader.getValue());
        }
    }

    // process user defined headers for information.
    Hashtable userHeaderTable = (Hashtable) msgContext.getProperty(HTTPConstants.REQUEST_HEADERS);

    if (userHeaderTable != null) {
        for (Iterator e = userHeaderTable.entrySet().iterator(); e.hasNext();) {
            Map.Entry me = (Map.Entry) e.next();
            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)) {
                method.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, true);
            } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
                String val = me.getValue().toString();
                if (null != val) {
                    httpChunkStream = JavaUtils.isTrue(val);
                }
            } else {
                method.addRequestHeader(key, value);
            }
        }
    }
}