Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HostConfiguration


    if( postMethod instanceof ExtendedPostMethod )
      ( ( ExtendedPostMethod )postMethod ).setRequestEntity( new InputStreamRequestEntity( capture, request
          .getContentType() ) );

    HostConfiguration hostConfiguration = new HostConfiguration();

    httpRequest.getProtocol();
    hostConfiguration.getParams().setParameter(
        SoapUIHostConfiguration.SOAPUI_SSL_CONFIG,
        settings.getString( SecurityTabForm.SSLTUNNEL_KEYSTOREPATH, "" ) + " "
            + settings.getString( SecurityTabForm.SSLTUNNEL_KEYSTOREPASSWORD, "" ) );
    hostConfiguration.setHost( new URI( this.prot + sslEndPoint, true ) );

    hostConfiguration = ProxyUtils.initProxySettings( settings, httpState, hostConfiguration, prot + sslEndPoint,
        new DefaultPropertyExpansionContext( project ) );

    if( sslEndPoint.indexOf( "/" ) < 0 )
View Full Code Here


{
  public void filterAbstractHttpRequest( SubmitContext context, AbstractHttpRequest<?> wsdlRequest )
  {
    // init proxy settings
    Settings settings = wsdlRequest.getSettings();
    HostConfiguration hostConfiguration = ( HostConfiguration )context
        .getProperty( BaseHttpRequestTransport.HOST_CONFIGURATION );
    HttpState httpState = ( HttpState )context.getProperty( SubmitContext.HTTP_STATE_PROPERTY );

    String endpoint = PropertyExpander.expandProperties( context, wsdlRequest.getEndpoint() );
    ProxyUtils.initProxySettings( settings, httpState, hostConfiguration, endpoint, context );
View Full Code Here

    if( method instanceof ExtendedPostMethod )
      ( ( ExtendedPostMethod )method ).setRequestEntity( new InputStreamRequestEntity( capture, request
          .getContentType() ) );

    HostConfiguration hostConfiguration = new HostConfiguration();

    StringBuffer url = new StringBuffer( "http://" );
    url.append( httpRequest.getServerName() );
    if( httpRequest.getServerPort() != 80 )
      url.append( ":" + httpRequest.getServerPort() );
    if( httpRequest.getServletPath() != null )
    {
      url.append( httpRequest.getServletPath() );
      method.setPath( httpRequest.getServletPath() );
      if( httpRequest.getQueryString() != null )
      {
        url.append( "?" + httpRequest.getQueryString() );
        method.setPath( httpRequest.getServletPath() + "?" + httpRequest.getQueryString() );
      }
    }
    hostConfiguration.setHost( new URI( url.toString(), true ) );

    // SoapUI.log("PROXY to:" + url);

    monitor.fireBeforeProxy( request, response, method, hostConfiguration );
View Full Code Here

      try
      {
        Settings soapuiSettings = SoapUI.getSettings();

        HttpClientSupport.applyHttpSettings( getMethod, soapuiSettings );
        HostConfiguration hostConfiguration = ProxyUtils.initProxySettings( soapuiSettings, state,
            new HostConfiguration(), getMethod.getURI().toString(), contextModelItem == null ? null
                : new DefaultPropertyExpansionContext( contextModelItem ) );

        httpClient.executeMethod( hostConfiguration, getMethod, state );
      }
      catch( Exception e )
View Full Code Here

  {
    // internalConnect.
    internalConnect();

    postMethod.setRequestEntity( new ByteArrayRequestEntity( outBuffer.toByteArray() ) );
    HostConfiguration hostConfiguration = new HostConfiguration();

    ProxyUtils.initProxySettings( context.getModelItem() == null ? SoapUI.getSettings() : context.getModelItem()
        .getSettings(), httpState, hostConfiguration, url, context );

    HttpClientSupport.getHttpClient().executeMethod( hostConfiguration, postMethod, httpState );
View Full Code Here

      httpState = new HttpState();
      submitContext.setProperty( SubmitContext.HTTP_STATE_PROPERTY, httpState );
      createdState = true;
    }

    HostConfiguration hostConfiguration = new HostConfiguration();

    String localAddress = System.getProperty( "soapui.bind.address", httpRequest.getBindAddress() );
    if( localAddress == null || localAddress.trim().length() == 0 )
      localAddress = SoapUI.getSettings().getString( HttpSettings.BIND_ADDRESS, null );

    if( localAddress != null && localAddress.trim().length() > 0 )
    {
      try
      {
        hostConfiguration.setLocalAddress( InetAddress.getByName( localAddress ) );
      }
      catch( Exception e )
      {
        SoapUI.logError( e, "Failed to set localAddress to [" + localAddress + "]" );
      }
    }

    submitContext.removeProperty( RESPONSE );
    submitContext.setProperty( HTTP_METHOD, httpMethod );
    submitContext.setProperty( POST_METHOD, httpMethod );
    submitContext.setProperty( HTTP_CLIENT, httpClient );
    submitContext.setProperty( REQUEST_CONTENT, httpRequest.getRequestContent() );
    submitContext.setProperty( HOST_CONFIGURATION, hostConfiguration );
    submitContext.setProperty( WSDL_REQUEST, httpRequest );
    submitContext.setProperty( RESPONSE_PROPERTIES, new StringToStringMap() );

    for( RequestFilter filter : filters )
    {
      filter.filterRequest( submitContext, httpRequest );
    }

    try
    {
      Settings settings = httpRequest.getSettings();

      // custom http headers last so they can be overridden
      StringToStringsMap headers = httpRequest.getRequestHeaders();

      // first remove so we don't get any unwanted duplicates
      for( String header : headers.keySet() )
      {
        httpMethod.removeRequestHeader( header );
      }

      // now add
      for( String header : headers.keySet() )
      {
        for( String headerValue : headers.get( header ) )
        {
          headerValue = PropertyExpander.expandProperties( submitContext, headerValue );
          httpMethod.addRequestHeader( header, headerValue );
        }
      }

      // do request
      WsdlProject project = ( WsdlProject )ModelSupport.getModelItemProject( httpRequest );
      WssCrypto crypto = null;
      if( project != null && project.getWssContainer() != null )
      {
        crypto = project.getWssContainer().getCryptoByName(
            PropertyExpander.expandProperties( submitContext, httpRequest.getSslKeystore() ) );
      }

      if( crypto != null && WssCrypto.STATUS_OK.equals( crypto.getStatus() ) )
      {
        hostConfiguration.getParams().setParameter( SoapUIHostConfiguration.SOAPUI_SSL_CONFIG,
            crypto.getSource() + " " + crypto.getPassword() );
      }

      // dump file?
      httpMethod.setDumpFile( PathUtils.expandPath( httpRequest.getDumpFile(),
          ( AbstractWsdlModelItem<?> )httpRequest, submitContext ) );

      // fix absolute URIs due to peculiarity in httpclient
      URI uri = ( URI )submitContext.getProperty( BaseHttpRequestTransport.REQUEST_URI );
      if( uri != null && uri.isAbsoluteURI() )
      {
        hostConfiguration.setHost( uri.getHost(), uri.getPort() );
        String str = uri.toString();
        int ix = str.indexOf( '/', str.indexOf( "//" ) + 2 );
        if( ix != -1 )
        {
          uri = new URI( str.substring( ix ), true );
View Full Code Here

    for( Header header : httpMethod.getRequestHeaders() )
      getMethod.addRequestHeader( header );

    URI uri = new URI( httpMethod.getResponseHeader( "Location" ).getValue(), true );
    getMethod.setURI( uri );
    HostConfiguration host = new HostConfiguration();
    host.setHost( uri );
    httpClient.executeMethod( host, getMethod, httpState );
    if( isRedirectResponse( getMethod ) )
    {
      if( redirectCount == 10 )
        throw new Exception( "Maximum number of Redirects reached [10]" );
View Full Code Here

        if (session != null) {
            httpClient = (HttpClient)session.getAttribute(HTTP_CLIENT);
        }
        if (httpClient == null) {
            httpClient = new HttpClient();
            HostConfiguration config = httpClient.getHostConfiguration();
            if (config == null) {
                config = new HostConfiguration();
            }
           
           
            /* TODO: fixme!
             * When the specified source sent to the wsproxy is not "http"
             * (e.g. "cocoon:/"), the HttpClient throws an exception.  Does the source
             * here need to be resolved before being set in the HostConfiguration?
             */
            try {
                uri = new URI(this.source);
                host = uri.getHost();
                config.setHost(uri);
            } catch (URIException ex) {
                throw new ProcessingException("URI format error: " + ex, ex);
            }

            // Check the http.nonProxyHosts to see whether or not the current
            // host needs to be served through the proxy server.
            boolean proxiableHost = true;
            String nonProxyHosts = System.getProperty("http.nonProxyHosts");
            if (nonProxyHosts != null)
            {
                StringTokenizer tok = new StringTokenizer(nonProxyHosts, "|");

                while (tok.hasMoreTokens()) {
                    String nonProxiableHost = tok.nextToken().trim();

                    // XXX is there any other characters that need to be
                    // escaped?
                    nonProxiableHost = StringUtils.replace(nonProxiableHost, ".", "\\.");
                    nonProxiableHost = StringUtils.replace(nonProxiableHost, "*", ".*");

                    // XXX do we want .example.com to match
                    // computer.example.com?  it seems to be a very common
                    // idiom for the nonProxyHosts, in that case then we want
                    // to change "^" to "^.*"
                    RE re = null;
                    try {
                        re = new RE("^" + nonProxiableHost + "$");
                    }
                    catch (Exception ex) {
                        throw new ProcessingException("Regex syntax error: " + ex, ex);
                    }

                    if (re.match(host))
                    {
                        proxiableHost = false;
                        break;
                    }
                }
            }

            if (proxiableHost && System.getProperty("http.proxyHost") != null) {
                String proxyHost = System.getProperty("http.proxyHost");
                int proxyPort = Integer.parseInt(System.getProperty("http.proxyPort"));
                config.setProxy(proxyHost, proxyPort);
            }

            httpClient.setHostConfiguration(config);

            session.setAttribute(HTTP_CLIENT, httpClient);
View Full Code Here

        if (src.isRelativeURI()) {
            throw new ProcessingException("Invalid URL \"" + src.toString() + "\"");
        }

        /* Configure the method with the resolved URL */
        HostConfiguration hc = new HostConfiguration();
        hc.setHost(src);
        this.method.setHostConfiguration(hc);
        this.method.setPath(src.getPath());
        this.method.setQueryString(src.getQuery());

        /* And now process the query string (from the parameters above) */
 
View Full Code Here

      params.setDefaultMaxConnectionsPerHost(MAX_THREADS_PER_HOST);
    } else {
      params.setDefaultMaxConnectionsPerHost(MAX_THREADS_TOTAL);
    }

    HostConfiguration hostConf = client.getHostConfiguration();
    if (PROXY) {
      hostConf.setProxy(PROXY_HOST, PROXY_PORT);
    }
    if (NTLM_USERNAME.length() > 0) {
      Credentials ntCreds = new NTCredentials(NTLM_USERNAME, NTLM_PASSWORD, NTLM_HOST, NTLM_DOMAIN);
      client.getState().setCredentials(new AuthScope(NTLM_HOST, AuthScope.ANY_PORT), ntCreds);
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.HostConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.