Package org.apache.http.impl.client

Examples of org.apache.http.impl.client.AbstractHttpClient


    debug(managePage);

  }

  private AbstractHttpClient buildClient() {
    AbstractHttpClient result = MechanizeAgent.buildDefaultHttpClient();

    System.setProperty("http.proxyHost", "127.0.0.1");
    System.setProperty("http.proxyPort", "8888");

    //          HttpHost proxy = new HttpHost("localhost", 8080);
    //          result.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

    ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(
        result.getConnectionManager().getSchemeRegistry(),
        ProxySelector.getDefault());
    result.setRoutePlanner(routePlanner);

    return result;
  }
View Full Code Here


     * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
     */
    protected void sendViaGet(MessageContext msgContext, URL url, String soapActionString)
            throws AxisFault {
        HttpGet httpGet = new HttpGet();
        AbstractHttpClient httpClient = getHttpClient(msgContext);
        MessageFormatter messageFormatter = populateCommonProperties(msgContext, url, httpGet,
                                                                     httpClient, soapActionString);

        // Need to have this here because we can have soap action when using the
        // soap response MEP
View Full Code Here

     */
    protected void sendViaDelete(MessageContext msgContext, URL url, String soapActionString)
            throws AxisFault {

        HttpDelete deleteMethod = new HttpDelete();
        AbstractHttpClient httpClient = getHttpClient(msgContext);
        populateCommonProperties(msgContext, url, deleteMethod, httpClient, soapActionString);

        /*
         * main execution takes place..
         */
 
View Full Code Here

     * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
     */
    protected void sendViaPost(MessageContext msgContext, URL url, String soapActionString)
            throws AxisFault {

        AbstractHttpClient httpClient = getHttpClient(msgContext);

        /*
         * What's up with this, it never gets used anywhere?? --Glen String
         * charEncoding = (String)
         * msgContext.getProperty(Constants.Configuration
 
View Full Code Here

     * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
     */
    protected void sendViaPut(MessageContext msgContext, URL url, String soapActionString)
            throws AxisFault {

        AbstractHttpClient httpClient = getHttpClient(msgContext);

        /*
         * Same deal - this value never gets used, why is it here? --Glen String
         * charEncoding = (String)
         * msgContext.getProperty(Constants.Configuration
 
View Full Code Here

    }

    protected AbstractHttpClient getHttpClient(MessageContext msgContext) {
        ConfigurationContext configContext = msgContext.getConfigurationContext();

        AbstractHttpClient httpClient = (AbstractHttpClient) msgContext
                .getProperty(HTTPConstants.CACHED_HTTP_CLIENT);

        if (httpClient == null) {
            httpClient = (AbstractHttpClient) configContext.
                    getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
View Full Code Here

  protected AbstractHttpClient createDefaultClient(ProxySelector selector)
  {
    SchemeRegistry schemeRegistry = this.createDefaultSchemeRegistry();
    ClientConnectionManager cm = this.createDefaultConnectionManager(schemeRegistry);
    HttpParams params = this.createDefaultHttpParams();
    AbstractHttpClient c = new DefaultHttpClient(cm, params);
    c.setRoutePlanner(this.createDefaultRoutePlanner(schemeRegistry, selector));
    return c;
  }
View Full Code Here

    if (isHttpSolrServer(solrServer)) {
      HttpSolrServer httpSolrServer = (HttpSolrServer) solrServer;

      if (credentials != null && StringUtils.isNotBlank(authPolicy)
          && assertHttpClientInstance(httpSolrServer.getHttpClient())) {
        AbstractHttpClient httpClient = (AbstractHttpClient) httpSolrServer.getHttpClient();
        httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY), credentials);
        httpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, Arrays.asList(authPolicy));
      }
    }
  }
View Full Code Here

            JerseyUtil.addHandlers(clientConfig, readers, writers);

            // create the client
            ApacheHttpClient4 client = ApacheHttpClient4.create(clientConfig);
            AbstractHttpClient httpClient = (AbstractHttpClient) client.getClientHandler().getHttpClient();

            // do not use Apache's retry handler
            httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));

            // use a RoutePlanner/ProxySelector that fits our requirements
            SchemeRegistry registry = httpClient.getConnectionManager().getSchemeRegistry();
            httpClient.setRoutePlanner(new ProxySelectorRoutePlanner(registry, proxySelector));

            JerseyUtil.addFilters(client, config);

            return client;
        } catch (Exception e) {
View Full Code Here

  @Test
  public void testInitFactoryWithAuthentication() {
    HttpSolrServerFactory factory = new HttpSolrServerFactory(solrServer, "core", new UsernamePasswordCredentials(
        "username", "password"), "BASIC");

    AbstractHttpClient solrHttpClient = (AbstractHttpClient) ((HttpSolrServer) factory.getSolrServer()).getHttpClient();
    Assert.assertNotNull(solrHttpClient.getCredentialsProvider().getCredentials(AuthScope.ANY));
    Assert.assertNotNull(solrHttpClient.getParams().getParameter(AuthPNames.TARGET_AUTH_PREF));
    Assert.assertEquals("username", ((UsernamePasswordCredentials) solrHttpClient.getCredentialsProvider()
        .getCredentials(AuthScope.ANY)).getUserName());
    Assert.assertEquals("password", ((UsernamePasswordCredentials) solrHttpClient.getCredentialsProvider()
        .getCredentials(AuthScope.ANY)).getPassword());
  }
View Full Code Here

TOP

Related Classes of org.apache.http.impl.client.AbstractHttpClient

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.