Examples of HostConfiguration


Examples of org.apache.commons.httpclient.HostConfiguration

        defaults.add(new Header("this-header", "value1"));
        defaults.add(new Header("that-header", "value1"));
        defaults.add(new Header("that-header", "value2"));
        defaults.add(new Header("User-Agent", "test"));

        HostConfiguration hostconfig = new HostConfiguration();
        hostconfig.setHost(
                this.server.getLocalAddress(),
                this.server.getLocalPort(),
                Protocol.getProtocol("http"));
        hostconfig.getParams().setParameter(HostParams.DEFAULT_HEADERS, defaults);
       
        GetMethod httpget = new GetMethod("/miss/");
        try {
            this.client.executeMethod(hostconfig, httpget);
        } finally {
View Full Code Here

Examples of org.apache.commons.httpclient.HostConfiguration

    public void testDefaults() throws IOException {
        this.server.setHttpService(new SimpleService());

        this.client.getParams().setParameter(HttpMethodParams.USER_AGENT, "test");
        HostConfiguration hostconfig = new HostConfiguration();
        hostconfig.setHost(
                this.server.getLocalAddress(),
                this.server.getLocalPort(),
                Protocol.getProtocol("http"));
       
        GetMethod httpget = new GetMethod("/miss/");
        try {
            this.client.executeMethod(hostconfig, httpget);
        } finally {
            httpget.releaseConnection();
        }
        assertEquals(HttpStatus.SC_OK, httpget.getStatusCode());
        assertEquals("test", httpget.getRequestHeader("User-Agent").getValue());
        assertEquals("test", httpget.getParams().
                getParameter(HttpMethodParams.USER_AGENT));
        assertEquals("test", hostconfig.getParams().
                getParameter(HttpMethodParams.USER_AGENT));
        assertEquals("test", client.getParams().
                getParameter(HttpMethodParams.USER_AGENT));
    }
View Full Code Here

Examples of org.apache.commons.httpclient.HostConfiguration

        return close;
    }

    private HostConfiguration getHostConfiguration(String locationURI, MessageExchange exchange, NormalizedMessage message)
        throws Exception {
        HostConfiguration host;
        URI uri = new URI(locationURI, false);
        if (uri.getScheme().equals("https")) {
            synchronized (this) {
                if (protocol == null) {
                    ProtocolSocketFactory sf = new CommonsHttpSSLSocketFactory(
                                    endpoint.getSsl(),
                                    endpoint.getKeystoreManager());
                    protocol = new Protocol("https", sf, 443);
                }
            }
            HttpHost httphost = new HttpHost(uri.getHost(), uri.getPort(), protocol);
            host = new HostConfiguration();
            host.setHost(httphost);
        } else {
            host = new HostConfiguration();
            host.setHost(uri.getHost(), uri.getPort());
        }
        if (endpoint.getProxy() != null) {
            if ((endpoint.getProxy().getProxyHost() != null) && (endpoint.getProxy().getProxyPort() != 0)) {
                host.setProxy(endpoint.getProxy().getProxyHost(), endpoint.getProxy().getProxyPort());
            }
            if (endpoint.getProxy().getProxyCredentials() != null) {
                endpoint.getProxy().getProxyCredentials().applyProxyCredentials(getClient(), exchange, message);
            }
        } else if ((getConfiguration().getProxyHost() != null) && (getConfiguration().getProxyPort() != 0)) {
            host.setProxy(getConfiguration().getProxyHost(), getConfiguration().getProxyPort());
        }
        return host;
    }
View Full Code Here

Examples of org.apache.commons.httpclient.HostConfiguration

    // executeMethod(HttpMethod) seems to ignore the connection timeout on the connection manager.
    // set it explicitly on the HttpClient.
    client.getParams().setConnectionManagerTimeout(timeout);

    HostConfiguration hostConf = client.getHostConfiguration();
    ArrayList headers = new ArrayList();
    // Set the User Agent in the header
    headers.add(new Header("User-Agent", userAgent));
    // prefer English
    headers.add(new Header("Accept-Language", acceptLanguage));
    // prefer UTF-8
    headers.add(new Header("Accept-Charset", "utf-8,ISO-8859-1;q=0.7,*;q=0.7"));
    // prefer understandable formats
    headers.add(new Header("Accept",
            "text/html,application/xml;q=0.9,application/xhtml+xml,text/xml;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"));
    // accept gzipped content
    headers.add(new Header("Accept-Encoding", "x-gzip, gzip, deflate"));
    hostConf.getParams().setParameter("http.default-headers", headers);

    // HTTP proxy server details
    if (useProxy) {
      hostConf.setProxy(proxyHost, proxyPort);

      if (proxyUsername.length() > 0) {

        AuthScope proxyAuthScope = getAuthScope(
            this.proxyHost, this.proxyPort, this.proxyRealm);
View Full Code Here

Examples of org.apache.commons.httpclient.HostConfiguration

   */
  private void httpProxy(SimpleHttpServerConnection conn, URI url) throws IOException {
    Log wireLog = LogFactory.getLog("httpclient.wire");
   
    HttpClient client = new HttpClient();
    HostConfiguration hc = new HostConfiguration();
    hc.setHost(url);
    client.setHostConfiguration(hc);
   
    //TODO support other methods
    HttpMethod method = new GetMethod(url.getPathQuery());
    Header[] headers = conn.getHeaders();
View Full Code Here

Examples of org.apache.commons.httpclient.HostConfiguration

        defaults.add(new Header("this-header", "value1"));
        defaults.add(new Header("that-header", "value1"));
        defaults.add(new Header("that-header", "value2"));
        defaults.add(new Header("User-Agent", "test"));

        HostConfiguration hostconfig = new HostConfiguration();
        hostconfig.setHost(
                this.server.getLocalAddress(),
                this.server.getLocalPort(),
                Protocol.getProtocol("http"));
        hostconfig.getParams().setParameter(HostParams.DEFAULT_HEADERS, defaults);
       
        GetMethod httpget = new GetMethod("/miss/");
        try {
            this.client.executeMethod(hostconfig, httpget);
        } finally {
View Full Code Here

Examples of org.apache.commons.httpclient.HostConfiguration

    public void testDefaults() throws IOException {
        this.server.setHttpService(new SimpleService());

        this.client.getParams().setParameter(HttpMethodParams.USER_AGENT, "test");
        HostConfiguration hostconfig = new HostConfiguration();
        hostconfig.setHost(
                this.server.getLocalAddress(),
                this.server.getLocalPort(),
                Protocol.getProtocol("http"));
       
        GetMethod httpget = new GetMethod("/miss/");
        try {
            this.client.executeMethod(hostconfig, httpget);
        } finally {
            httpget.releaseConnection();
        }
        assertEquals(HttpStatus.SC_OK, httpget.getStatusCode());
        assertEquals("test", httpget.getRequestHeader("User-Agent").getValue());
        assertEquals("test", httpget.getParams().
                getParameter(HttpMethodParams.USER_AGENT));
        assertEquals("test", hostconfig.getParams().
                getParameter(HttpMethodParams.USER_AGENT));
        assertEquals("test", client.getParams().
                getParameter(HttpMethodParams.USER_AGENT));
    }
View Full Code Here

Examples of org.apache.commons.httpclient.HostConfiguration

            throw new RepositoryException(e);
        }

        try {
            URI repositoryUri = new URI((uri.endsWith("/")) ? uri : uri+"/", true);
            hostConfig = new HostConfiguration();
            hostConfig.setHost(repositoryUri);

            nsCache = new NamespaceCache();
            uriResolver = new URIResolverImpl(repositoryUri, this, domFactory);
            NamePathResolver resolver = new NamePathResolverImpl(nsCache);
View Full Code Here

Examples of org.apache.commons.httpclient.HostConfiguration

        session.connect();
        return session;
    }

    protected void checkHtmlPage(HttpClient client, URL url) throws IOException {
        client.setHostConfiguration(new HostConfiguration());
        client.getHostConfiguration().setHost(url.getHost(), url.getPort());
        GetMethod get = new GetMethod("");
        get.getParams().setVersion(HttpVersion.HTTP_1_1);
        client.executeMethod(get);
        String str = get.getResponseBodyAsString();
View Full Code Here

Examples of org.apache.commons.httpclient.HostConfiguration

        this.qValueFactory = qValueFactory;
        this.itemInfoCacheSize = itemInfoCacheSize;

        try {
            URI repositoryUri = new URI((uri.endsWith("/")) ? uri : uri+"/", true);
            hostConfig = new HostConfiguration();
            hostConfig.setHost(repositoryUri);

            nsCache = new NamespaceCache();
            uriResolver = new URIResolverImpl(repositoryUri, this, DomUtil.createDocument());
            NamePathResolver resolver = new NamePathResolverImpl(nsCache);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.