Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 4674 invoked from network); 19 Aug 2005 14:19:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Aug 2005 14:19:47 -0000 Received: (qmail 30140 invoked by uid 500); 19 Aug 2005 14:12:01 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 29851 invoked by uid 500); 19 Aug 2005 14:11:59 -0000 Mailing-List: contact axis-dev-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@ws.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-dev@ws.apache.org Received: (qmail 29727 invoked by uid 99); 19 Aug 2005 14:11:59 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=SPF_FAIL X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Aug 2005 07:11:56 -0700 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id DBF9DE4 for ; Fri, 19 Aug 2005 16:11:54 +0200 (CEST) Message-ID: <1405046578.1124460714899.JavaMail.jira@ajax.apache.org> Date: Fri, 19 Aug 2005 16:11:54 +0200 (CEST) From: =?UTF-8?Q?Javier_C=C3=A1mara_=28JIRA=29?= To: axis-dev@ws.apache.org Subject: [jira] Commented: (AXIS-1994) CommonsHTTPSender failing to set host name In-Reply-To: <1006806122.1115980266157.JavaMail.jira@ajax.apache.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/AXIS-1994?page=3Dcomments#action= _12319383 ]=20 Javier C=C3=A1mara commented on AXIS-1994: ------------------------------------- Hi Jayachandra! The section of code being patched is not the one when the host "is listed i= n the proxy list", but when the host "is not listed in the non-proxy list".= This is, when there is a proxy set and the target host is not in the list = of hosts for which the proxy must not be used. I do not think your guess about config.setHost() annullating the effect of = config.setProxy() is correct. From the documentation and source of CommonsH= TTP, HttpConnectionParams is just a container of variables specifying the h= ost and port you want to connect to, and the proxy to be used, if any. This= means that, if you want to connect to a host using a proxy, you must speci= fy both, and not only the proxy, and thus calling setHost() is independent = of calling setProxy(). The exception being thrown is not an unhandled one, but an explicit one. Th= is is the code of org.apache.commons.httpclient.HttpConnection causing it: if (host =3D=3D null) { throw new IllegalArgumentException("host parameter is null"); } For me it is clear that CommonsHTTPSender is blatantly wrong when not setti= ng a host name before invoking HttpConnection, as it does in other cases, a= nd makes me think that this case has not been tested. Thus my simple patch. If you want to reproduce the problem, all you have to do to use CommonsHTTP= Sender through a proxy. My original test was with a proxy requesting NTLM a= uthentication, but it fails equally when the proxy does not require any aut= hentication at all, and I guess it will too if it requires BASIC authentica= tion. If you do not have a proxy at hand I think you can use TCPMon as one.= This is how I am getting the exception (with a proxy without authenticatio= n): - Configure client-config.wsdd to use CommonsHTTPSender instead of HTTPSend= er - Put client-config.wsdd in the classpath along with commons-codec-1.3.jar - Set the system properties http.proxyHost, http.proxyPort If you are not able to reproduce the original problem with this configurati= on, please tell me because there must be some mistake somewhere. Regards > CommonsHTTPSender failing to set host name > ------------------------------------------ > > Key: AXIS-1994 > URL: http://issues.apache.org/jira/browse/AXIS-1994 > Project: Apache Axis > Type: Bug > Components: Basic Architecture > Versions: 1.2 > Reporter: Javier C=C3=A1mara > Assignee: Jayachandra Sekhara Rao Sunkara > Priority: Minor > > I tried to use Axis 1.2 to trespass a firewall with NTLM authentication (= I think it is NTLM; at least it asks for an Active Directory Domain).=20 > I configured client-config.wsdd to use CommonsHTTPSender, and installed c= ommons-codec-1.3.jar in the classpath. But I got the following exception: > =20 > java.lang.IllegalArgumentException: host parameter is null > at org.apache.commons.httpclient.HttpConnection.<init>(Http= Connection.java:206) > at org.apache.commons.httpclient.HttpConnection.<init>(Http= Connection.java:155) > at org.apache.commons.httpclient.MultiThreadedHttpConnectionManag= er$HttpConnectionWithReference.<init>(MultiThreadedHttpConnectionMana= ger.java:1123) > at org.apache.commons.httpclient.MultiThreadedHttpConnectionManag= er$ConnectionPool.createConnection(MultiThreadedHttpConnectionManager.java:= 748) > at org.apache.commons.httpclient.MultiThreadedHttpConnectionManag= er.doGetConnection(MultiThreadedHttpConnectionManager.java:469) > at org.apache.commons.httpclient.MultiThreadedHttpConnectionManag= er.getConnectionWithTimeout(MultiThreadedHttpConnectionManager.java:394) > at org.apache.commons.httpclient.HttpMethodDirector.executeMethod= (HttpMethodDirector.java:152) > at org.apache.commons.httpclient.HttpClient.executeMethod(HttpCli= ent.java:393) > at org.apache.axis.transport.http.CommonsHTTPSender.invoke(Common= sHTTPSender.java:186) > at org.apache.axis.strategies.InvocationStrategy.visit(Invocation= Strategy.java:32) > at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) > at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) > at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) > at org.apache.axis.client.Call.invokeEngine(Call.java:2765) > at org.apache.axis.client.Call.invoke(Call.java:2748) > at org.apache.axis.client.Call.invoke(Call.java:1784) > (...) > =20 > Then I had a look into CommonsHTTPSender and saw that the getHostConfigur= ation(HttpClient, MessageContext, URL) method seemed to fail to call config= .setHost() when there is a proxy host. I patched it. After that I still got= an error, but related to the Commons HTTP Library and not CommonsHTTPSende= r. > Since it seems to be no attachement feature in JIRA I guess I have to cop= y & paste my patch here. I will post the entire file; I just added line 390= (marked as "JCM"): > /* > * Copyright 2001-2004 The Apache Software Foundation. > *=20 > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > * You may obtain a copy of the License at > *=20 > * http://www.apache.org/licenses/LICENSE-2.0 > *=20 > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie= d. > * See the License for the specific language governing permissions and > * limitations under the License. > */ > package org.apache.axis.transport.http; > import org.apache.axis.AxisFault; > import org.apache.axis.Constants; > import org.apache.axis.Message; > import org.apache.axis.MessageContext; > import org.apache.axis.components.logger.LogFactory; > import org.apache.axis.components.net.CommonsHTTPClientProperties; > import org.apache.axis.components.net.CommonsHTTPClientPropertiesFactory; > import org.apache.axis.components.net.TransportClientProperties; > import org.apache.axis.components.net.TransportClientPropertiesFactory; > import org.apache.axis.handlers.BasicHandler; > import org.apache.axis.soap.SOAP12Constants; > import org.apache.axis.soap.SOAPConstants; > import org.apache.axis.utils.Messages; > import org.apache.axis.utils.NetworkUtils; > import org.apache.commons.httpclient.Cookie; > import org.apache.commons.httpclient.Credentials; > import org.apache.commons.httpclient.Header; > import org.apache.commons.httpclient.HostConfiguration; > import org.apache.commons.httpclient.HttpClient; > import org.apache.commons.httpclient.HttpConnectionManager; > import org.apache.commons.httpclient.HttpMethodBase; > import org.apache.commons.httpclient.HttpState; > import org.apache.commons.httpclient.HttpVersion; > import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; > import org.apache.commons.httpclient.NTCredentials; > import org.apache.commons.httpclient.UsernamePasswordCredentials; > import org.apache.commons.httpclient.auth.AuthScope; > import org.apache.commons.httpclient.cookie.CookiePolicy; > import org.apache.commons.httpclient.methods.GetMethod; > import org.apache.commons.httpclient.methods.PostMethod; > import org.apache.commons.httpclient.methods.RequestEntity; > import org.apache.commons.httpclient.params.HttpMethodParams; > import org.apache.commons.logging.Log; > import javax.xml.soap.MimeHeader; > import javax.xml.soap.MimeHeaders; > import javax.xml.soap.SOAPException; > import java.io.FilterInputStream; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > import java.net.URL; > import java.util.Hashtable; > import java.util.Iterator; > import java.util.Map; > import java.util.StringTokenizer; > import java.util.ArrayList; > /** > * This class uses Jakarta Commons's HttpClient to call a SOAP server. > * > * @author Davanum Srinivas (dims@yahoo.com) > * History: By Chandra Talluri > * Modifications done for maintaining sessions. Cookies needed to be set = on > * HttpState not on MessageContext, since ttpMethodBase overwrites the co= okies=20 > * from HttpState. Also we need to setCookiePolicy on HttpState to=20 > * CookiePolicy.COMPATIBILITY else it is defaulting to RFC2109Spec and ad= ding=20 > * Version information to it and tomcat server not recognizing it > */ > public class CommonsHTTPSender extends BasicHandler { > =20 > /** Field log */ > protected static Log log =3D > LogFactory.getLog(CommonsHTTPSender.class.getName()); > =20 > protected HttpConnectionManager connectionManager; > protected CommonsHTTPClientProperties clientProperties; > =20 > public CommonsHTTPSender() { > initialize(); > } > protected void initialize() { > MultiThreadedHttpConnectionManager cm =3D new MultiThreadedHttpCo= nnectionManager(); > this.clientProperties =3D CommonsHTTPClientPropertiesFactory.crea= te(); > cm.getParams().setDefaultMaxConnectionsPerHost(clientProperties.g= etMaximumConnectionsPerHost()); > cm.getParams().setMaxTotalConnections(clientProperties.getMaximum= TotalConnections()); > // If defined, set the default timeouts > // Can be overridden by the MessageContext > if(this.clientProperties.getDefaultConnectionTimeout()>0) { > cm.getParams().setConnectionTimeout(this.clientProperties.getD= efaultConnectionTimeout()); > } > if(this.clientProperties.getDefaultSoTimeout()>0) { > cm.getParams().setSoTimeout(this.clientProperties.getDefaultSo= Timeout()); > } > this.connectionManager =3D cm; > } > =20 > /** > * invoke creates a socket connection, sends the request SOAP message= and then > * reads the response SOAP message back from the SOAP server > * > * @param msgContext the messsage context > * > * @throws AxisFault > */ > public void invoke(MessageContext msgContext) throws AxisFault { > HttpMethodBase method =3D null; > if (log.isDebugEnabled()) { > log.debug(Messages.getMessage("enter00", > "CommonsHTTPSender::invoke")); > } > try { > URL targetURL =3D > new URL(msgContext.getStrProp(MessageContext.TRANS_URL)); > =20 > // no need to retain these, as the cookies/credentials are > // stored in the message context across multiple requests. > // the underlying connection manager, however, is retained > // so sockets get recycled when possible. > HttpClient httpClient =3D new HttpClient(this.connectionManag= er); > // the timeout value for allocation of connections from the p= ool > httpClient.getParams().setConnectionManagerTimeout(this.clien= tProperties.getConnectionPoolTimeout()); > HostConfiguration hostConfiguration =3D=20 > getHostConfiguration(httpClient, msgContext, targetURL); > =20 > boolean posting =3D true; > =20 > // If we're SOAP 1.2, allow the web method to be set from the > // MessageContext. > if (msgContext.getSOAPConstants() =3D=3D SOAPConstants.SOAP12= _CONSTANTS) { > String webMethod =3D msgContext.getStrProp(SOAP12Constant= s.PROP_WEBMETHOD); > if (webMethod !=3D null) { > posting =3D webMethod.equals(HTTPConstants.HEADER_POS= T); > } > } > if (posting) { > Message reqMessage =3D msgContext.getRequestMessage(); > method =3D new PostMethod(targetURL.toString()); > // set false as default, addContetInfo can overwrite > method.getParams().setBooleanParameter(HttpMethodParams.U= SE_EXPECT_CONTINUE, > false); > =20 > addContextInfo(method, httpClient, msgContext, targetURL)= ; > ((PostMethod)method).setRequestEntity( > new MessageRequestEntity(m= ethod, reqMessage)); > } else { > method =3D new GetMethod(targetURL.toString()); > addContextInfo(method, httpClient, msgContext, targetURL)= ; > } > String httpVersion =3D=20 > msgContext.getStrProp(MessageContext.HTTP_TRANSPORT_VERSI= ON); > if (httpVersion !=3D null) { > if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_V10)= ) { > method.getParams().setVersion(HttpVersion.HTTP_1_0); > } > // assume 1.1 > } > =20 > // don't forget the cookies! > // Cookies need to be set on HttpState, since HttpMethodBase= =20 > // overwrites the cookies from HttpState > if (msgContext.getMaintainSession()) { > HttpState state =3D httpClient.getState(); > method.getParams().setCookiePolicy(CookiePolicy.BROWSER_C= OMPATIBILITY); > String host =3D hostConfiguration.getHost(); > String path =3D targetURL.getPath(); > boolean secure =3D hostConfiguration.getProtocol().isSecu= re(); > fillHeaders(msgContext, state, HTTPConstants.HEADER_COOKI= E, host, path, secure); > fillHeaders(msgContext, state, HTTPConstants.HEADER_COOKI= E2, host, path, secure); > httpClient.setState(state); > } > int returnCode =3D httpClient.executeMethod(hostConfiguration= , method, null); > String contentType =3D=20 > getHeader(method, HTTPConstants.HEADER_CONTENT_TYPE); > String contentLocation =3D=20 > getHeader(method, HTTPConstants.HEADER_CONTENT_LOCATION); > String contentLength =3D=20 > getHeader(method, HTTPConstants.HEADER_CONTENT_LENGTH); > if ((returnCode > 199) && (returnCode < 300)) { > =20 > // SOAP return is OK - so fall through > } else if (msgContext.getSOAPConstants() =3D=3D > SOAPConstants.SOAP12_CONSTANTS) { > // For now, if we're SOAP 1.2, fall through, since the ra= nge of > // valid result codes is much greater > } else if ((contentType !=3D null) && !contentType.equals("te= xt/html") > && ((returnCode > 499) && (returnCode < 600))) { > =20 > // SOAP Fault should be in here - so fall through > } else { > String statusMessage =3D method.getStatusText(); > AxisFault fault =3D new AxisFault("HTTP", > "(" + returnCode + ")" > + statusMessage, null, > null); > =20 > try { > fault.setFaultDetailString( > Messages.getMessage("return01", > "" + returnCode, > method.getResponseBodyAsStri= ng())); > fault.addFaultDetail(Constants.QNAME_FAULTDETAIL_HTTP= ERRORCODE, > Integer.toString(returnCode)); > throw fault; > } finally { > method.releaseConnection(); // release connection bac= k to pool. > } > } > =20 > // wrap the response body stream so that close() also release= s=20 > // the connection back to the pool. > InputStream releaseConnectionOnCloseStream =3D=20 > createConnectionReleasingInputStream(method); > Message outMsg =3D new Message(releaseConnectionOnCloseStream= , > false, contentType, contentLocat= ion); > // Transfer HTTP headers of HTTP message to MIME headers of S= OAP message > Header[] responseHeaders =3D method.getResponseHeaders(); > MimeHeaders responseMimeHeaders =3D outMsg.getMimeHeaders(); > for (int i =3D 0; i < responseHeaders.length; i++) { > Header responseHeader =3D responseHeaders[i]; > responseMimeHeaders.addHeader(responseHeader.getName(),= =20 > responseHeader.getValue()); > } > outMsg.setMessageType(Message.RESPONSE); > msgContext.setResponseMessage(outMsg); > if (log.isDebugEnabled()) { > if (null =3D=3D contentLength) { > log.debug("\n" > + Messages.getMessage("no00", "Content-Length")); > } > log.debug("\n" + Messages.getMessage("xmlRecd00")); > log.debug("----------------------------------------------= -"); > log.debug(outMsg.getSOAPPartAsString()); > } > =20 > // if we are maintaining session state, > // handle cookies (if any) > if (msgContext.getMaintainSession()) { > Header[] headers =3D method.getResponseHeaders(); > ArrayList cookies =3D new ArrayList(); > ArrayList cookies2 =3D new ArrayList(); > for (int i =3D 0; i < headers.length; i++) { > if (headers[i].getName().equalsIgnoreCase(HTTPConstan= ts.HEADER_SET_COOKIE)) { > cookies.add(cleanupCookie(headers[i].getValue()))= ; > } else if (headers[i].getName().equalsIgnoreCase(HTTP= Constants.HEADER_SET_COOKIE2)) { > cookies2.add(cleanupCookie(headers[i].getValue())= ); > } > } > if(cookies.size()=3D=3D1) { > msgContext.setProperty(HTTPConstants.HEADER_COOKIE, c= ookies.get(0)); > } else if (cookies.size() > 1) { > msgContext.setProperty(HTTPConstants.HEADER_COOKIE, c= ookies.toArray(new String[cookies.size()])); > } > if(cookies2.size()=3D=3D1) { > msgContext.setProperty(HTTPConstants.HEADER_COOKIE2, = cookies2.get(0)); > } else if (cookies2.size() > 1) { > msgContext.setProperty(HTTPConstants.HEADER_COOKIE2, = cookies2.toArray(new String[cookies2.size()])); > } > } > // always release the connection back to the pool if=20 > // it was one way invocation > if (msgContext.isPropertyTrue("axis.one.way")) { > method.releaseConnection(); > } > =20 > } catch (Exception e) { > log.debug(e); > throw AxisFault.makeFault(e); > } > =20 > if (log.isDebugEnabled()) { > log.debug(Messages.getMessage("exit00", > "CommonsHTTPSender::invoke")); > } > } > /** > * Add cookies from message context > * > * @param msgContext > * @param state > * @param header > * @param host > * @param path > * @param secure > */ > private void fillHeaders(MessageContext msgContext, HttpState state, = String header, String host, String path, boolean secure) { > Object ck1 =3D msgContext.getProperty(header); > if (ck1 !=3D null) { > if (ck1 instanceof String[]) { > String [] cookies =3D (String[]) ck1; > for (int i =3D 0; i < cookies.length; i++) { > addCookie(state, cookies[i], host, path, secure); > } > } else { > addCookie(state, (String) ck1, host, path, secure); > } > } > } > /** > * add cookie to state > * @param state > * @param cookie > */ > private void addCookie(HttpState state, String cookie,String host, St= ring path, boolean secure) { > int index =3D cookie.indexOf('=3D'); > state.addCookie(new Cookie(host, cookie.substring(0, index), > cookie.substring(index + 1), path, > null, secure)); > } > /** > * cleanup the cookie value. > * > * @param cookie initial cookie value > * > * @return a cleaned up cookie value. > */ > private String cleanupCookie(String cookie) { > cookie =3D cookie.trim(); > // chop after first ; a la Apache SOAP (see HTTPUtils.java there) > int index =3D cookie.indexOf(';'); > if (index !=3D -1) { > cookie =3D cookie.substring(0, index); > } > return cookie; > } > =20 > protected HostConfiguration getHostConfiguration(HttpClient client,= =20 > MessageContext conte= xt, > URL targetURL) { > TransportClientProperties tcp =3D=20 > TransportClientPropertiesFactory.create(targetURL.getProtocol= ()); // http or https > int port =3D targetURL.getPort(); > boolean hostInNonProxyList =3D > isHostInNonProxyList(targetURL.getHost(), tcp.getNonProxyHost= s()); > =20 > HostConfiguration config =3D new HostConfiguration(); > =20 > if (port =3D=3D -1) { > port =3D 80; // even for https > } > =20 > if(hostInNonProxyList){ > config.setHost(targetURL.getHost(), port, targetURL.getProtoc= ol()); > } else { > if (tcp.getProxyHost().length() =3D=3D 0 || > tcp.getProxyPort().length() =3D=3D 0) { > config.setHost(targetURL.getHost(), port, targetURL.getPr= otocol()); > } else { > if (tcp.getProxyUser().length() !=3D 0) { > Credentials proxyCred =3D=20 > new UsernamePasswordCredentials(tcp.getProxyUser(= ), > tcp.getProxyPassw= ord()); > // if the username is in the form "user\domain"=20 > // then use NTCredentials instead. > int domainIndex =3D tcp.getProxyUser().indexOf("\\"); > if (domainIndex > 0) { > String domain =3D tcp.getProxyUser().substring(0,= domainIndex); > if (tcp.getProxyUser().length() > domainIndex + 1= ) { > String user =3D tcp.getProxyUser().substring(= domainIndex + 1); > proxyCred =3D new NTCredentials(user, > tcp.getProxyPassword(), > tcp.getProxyHost(), domain); > } > } > client.getState().setProxyCredentials(AuthScope.ANY, = proxyCred); > } > int proxyPort =3D new Integer(tcp.getProxyPort()).intValu= e(); > config.setProxy(tcp.getProxyHost(), proxyPort); > config.setHost(targetURL.getHost(), port, targetURL.getPr= otocol()); // JCM May 2005 > } > } > return config; > } > =20 > /** > * Extracts info from message context. > * > * @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,=20 > HttpClient httpClient,=20 > MessageContext msgContext,=20 > URL tmpURL) > throws Exception { > =20 > // optionally set a timeout for the request > if (msgContext.getTimeout() !=3D 0) { > /* ISSUE: these are not the same, but MessageContext has only= one > definition of timeout */ > // SO_TIMEOUT -- timeout for blocking reads > httpClient.getHttpConnectionManager().getParams().setSoTimeou= t(msgContext.getTimeout()); > // timeout for initial connection > httpClient.getHttpConnectionManager().getParams().setConnecti= onTimeout(msgContext.getTimeout()); > } > =20 > // Get SOAPAction, default to "" > String action =3D msgContext.useSOAPAction() > ? msgContext.getSOAPActionURI() > : ""; > =20 > if (action =3D=3D null) { > action =3D ""; > } > Message msg =3D msgContext.getRequestMessage(); > if (msg !=3D null){ > method.setRequestHeader(new Header(HTTPConstants.HEADER_CONTE= NT_TYPE, > msg.getContentType(msgCont= ext.getSOAPConstants()))); > } > method.setRequestHeader(new Header(HTTPConstants.HEADER_SOAP_ACTI= ON,=20 > "\"" + action + "\"")); > String userID =3D msgContext.getUsername(); > String passwd =3D msgContext.getPassword(); > =20 > // if UserID is not part of the context, but is in the URL, use > // the one in the URL. > if ((userID =3D=3D null) && (tmpURL.getUserInfo() !=3D null)) { > String info =3D tmpURL.getUserInfo(); > int sep =3D info.indexOf(':'); > =20 > if ((sep >=3D 0) && (sep + 1 < info.length())) { > userID =3D info.substring(0, sep); > passwd =3D info.substring(sep + 1); > } else { > userID =3D info; > } > } > if (userID !=3D null) { > Credentials proxyCred =3D > new UsernamePasswordCredentials(userID, > passwd); > // if the username is in the form "user\domain" > // then use NTCredentials instead. > int domainIndex =3D userID.indexOf("\\"); > if (domainIndex > 0) { > String domain =3D userID.substring(0, domainIndex); > if (userID.length() > domainIndex + 1) { > String user =3D userID.substring(domainIndex + 1); > proxyCred =3D new NTCredentials(user, > passwd, > NetworkUtils.getLocalHostname(), doma= in); > } > } > httpClient.getState().setCredentials(AuthScope.ANY, proxyCred= ); > } > =20 > // Transfer MIME headers of SOAPMessage to HTTP headers.=20 > MimeHeaders mimeHeaders =3D msg.getMimeHeaders(); > if (mimeHeaders !=3D null) { > for (Iterator i =3D mimeHeaders.getAllHeaders(); i.hasNext();= ) { > MimeHeader mimeHeader =3D (MimeHeader) i.next(); > method.addRequestHeader(mimeHeader.getName(),=20 > mimeHeader.getValue()); > } > } > // process user defined headers for information. > Hashtable userHeaderTable =3D > (Hashtable) msgContext.getProperty(HTTPConstants.REQUEST_HEAD= ERS); > =20 > if (userHeaderTable !=3D null) { > for (Iterator e =3D userHeaderTable.entrySet().iterator(); > e.hasNext();) { > Map.Entry me =3D (Map.Entry) e.next(); > Object keyObj =3D me.getKey(); > =20 > if (null =3D=3D keyObj) { > continue; > } > String key =3D keyObj.toString().trim(); > String value =3D me.getValue().toString().trim(); > =20 > if (key.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT) && > value.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT_10= 0_Continue)) { > method.getParams().setBooleanParameter(HttpMethodPara= ms.USE_EXPECT_CONTINUE, > true); > } else { > method.addRequestHeader(key, value); > } > } > } > } > =20 > /** > * Check if the specified host is in the list of non proxy hosts. > * > * @param host host name > * @param nonProxyHosts string containing the list of non proxy hosts > * > * @return true/false > */ > protected boolean isHostInNonProxyList(String host, String nonProxyHo= sts) { > =20 > if ((nonProxyHosts =3D=3D null) || (host =3D=3D null)) { > return false; > } > =20 > /* > * The http.nonProxyHosts system property is a list enclosed in > * double quotes with items separated by a vertical bar. > */ > StringTokenizer tokenizer =3D new StringTokenizer(nonProxyHosts, = "|\""); > =20 > while (tokenizer.hasMoreTokens()) { > String pattern =3D tokenizer.nextToken(); > =20 > if (log.isDebugEnabled()) { > log.debug(Messages.getMessage("match00", > new String[]{"HTTPSender", > host, > pattern})); > } > if (match(pattern, host, false)) { > return true; > } > } > return false; > } > =20 > /** > * Matches a string against a pattern. The pattern contains two speci= al > * characters: > * '*' which means zero or more characters, > * > * @param pattern the (non-null) pattern to match against > * @param str the (non-null) string that must be matched against = the > * pattern > * @param isCaseSensitive > * > * @return true when the string matches against the patt= ern, > * false otherwise. > */ > protected static boolean match(String pattern, String str, > boolean isCaseSensitive) { > =20 > char[] patArr =3D pattern.toCharArray(); > char[] strArr =3D str.toCharArray(); > int patIdxStart =3D 0; > int patIdxEnd =3D patArr.length - 1; > int strIdxStart =3D 0; > int strIdxEnd =3D strArr.length - 1; > char ch; > boolean containsStar =3D false; > =20 > for (int i =3D 0; i < patArr.length; i++) { > if (patArr[i] =3D=3D '*') { > containsStar =3D true; > break; > } > } > if (!containsStar) { > =20 > // No '*'s, so we make a shortcut > if (patIdxEnd !=3D strIdxEnd) { > return false; // Pattern and string do not have th= e same size > } > for (int i =3D 0; i <=3D patIdxEnd; i++) { > ch =3D patArr[i]; > if (isCaseSensitive && (ch !=3D strArr[i])) { > return false; // Character mismatch > } > if (!isCaseSensitive > && (Character.toUpperCase(ch) > !=3D Character.toUpperCase(strArr[i]))) { > return false; // Character mismatch > } > } > return true; // String matches against pattern > } > if (patIdxEnd =3D=3D 0) { > return true; // Pattern contains only '*', which matches a= nything > } > =20 > // Process characters before first star > while ((ch =3D patArr[patIdxStart]) !=3D '*' > && (strIdxStart <=3D strIdxEnd)) { > if (isCaseSensitive && (ch !=3D strArr[strIdxStart])) { > return false; // Character mismatch > } > if (!isCaseSensitive > && (Character.toUpperCase(ch) > !=3D Character.toUpperCase(strArr[strIdxStart]))) { > return false; // Character mismatch > } > patIdxStart++; > strIdxStart++; > } > if (strIdxStart > strIdxEnd) { > =20 > // All characters in the string are used. Check if only '*'s = are > // left in the pattern. If so, we succeeded. Otherwise failur= e. > for (int i =3D patIdxStart; i <=3D patIdxEnd; i++) { > if (patArr[i] !=3D '*') { > return false; > } > } > return true; > } > =20 > // Process characters after last star > while ((ch =3D patArr[patIdxEnd]) !=3D '*' && (strIdxStart <=3D s= trIdxEnd)) { > if (isCaseSensitive && (ch !=3D strArr[strIdxEnd])) { > return false; // Character mismatch > } > if (!isCaseSensitive > && (Character.toUpperCase(ch) > !=3D Character.toUpperCase(strArr[strIdxEnd]))) { > return false; // Character mismatch > } > patIdxEnd--; > strIdxEnd--; > } > if (strIdxStart > strIdxEnd) { > =20 > // All characters in the string are used. Check if only '*'s = are > // left in the pattern. If so, we succeeded. Otherwise failur= e. > for (int i =3D patIdxStart; i <=3D patIdxEnd; i++) { > if (patArr[i] !=3D '*') { > return false; > } > } > return true; > } > =20 > // process pattern between stars. padIdxStart and patIdxEnd point > // always to a '*'. > while ((patIdxStart !=3D patIdxEnd) && (strIdxStart <=3D strIdxEn= d)) { > int patIdxTmp =3D -1; > =20 > for (int i =3D patIdxStart + 1; i <=3D patIdxEnd; i++) { > if (patArr[i] =3D=3D '*') { > patIdxTmp =3D i; > break; > } > } > if (patIdxTmp =3D=3D patIdxStart + 1) { > =20 > // Two stars next to each other, skip the first one. > patIdxStart++; > continue; > } > =20 > // Find the pattern between padIdxStart & padIdxTmp in str be= tween > // strIdxStart & strIdxEnd > int patLength =3D (patIdxTmp - patIdxStart - 1); > int strLength =3D (strIdxEnd - strIdxStart + 1); > int foundIdx =3D -1; > =20 > strLoop: > for (int i =3D 0; i <=3D strLength - patLength; i++) { > for (int j =3D 0; j < patLength; j++) { > ch =3D patArr[patIdxStart + j + 1]; > if (isCaseSensitive > && (ch !=3D strArr[strIdxStart + i + j])) { > continue strLoop; > } > if (!isCaseSensitive && (Character > .toUpperCase(ch) !=3D Character > .toUpperCase(strArr[strIdxStart + i + j]))) { > continue strLoop; > } > } > foundIdx =3D strIdxStart + i; > break; > } > if (foundIdx =3D=3D -1) { > return false; > } > patIdxStart =3D patIdxTmp; > strIdxStart =3D foundIdx + patLength; > } > =20 > // All characters in the string are used. Check if only '*'s are = left > // in the pattern. If so, we succeeded. Otherwise failure. > for (int i =3D patIdxStart; i <=3D patIdxEnd; i++) { > if (patArr[i] !=3D '*') { > return false; > } > } > return true; > } > private static String getHeader(HttpMethodBase method, String headerN= ame) { > Header header =3D method.getResponseHeader(headerName); > return (header =3D=3D null) ? null : header.getValue().trim(); > } > private InputStream createConnectionReleasingInputStream(final HttpMe= thodBase method) throws IOException { > return new FilterInputStream(method.getResponseBodyAsStream()) { > public void close() throws IOException { > try { > super.close(); > } finally { > method.releaseConnection(); > } > } > }; > } > private static class MessageRequestEntity implements RequestEntity { > =20 > private HttpMethodBase method; > private Message message; > public MessageRequestEntity(HttpMethodBase method, Message messag= e) { > this.message =3D message; > this.method =3D method; > } > public boolean isRepeatable() { > return true; > } > public void writeRequest(OutputStream out) throws IOException { > try { > this.message.writeTo(out); > } catch (SOAPException e) { > throw new IOException(e.getMessage()); > } > } > public long getContentLength() { > if (this.method.getParams().getVersion() =3D=3D HttpVersion.H= TTP_1_0) { > try { > return message.getContentLength(); > } catch (Exception e) { > return -1; /* -1 for chunked */ > } > } else { > return -1; /* -1 for chunked */ > } > } > public String getContentType() { > return null; // a separate header is added > } > =20 > } > } --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira