Package org.apache.commons.httpclient.protocol

Examples of org.apache.commons.httpclient.protocol.Protocol


    }

    public void testConnTimeout() {

        // create a custom protocol that will delay for 500 milliseconds
        Protocol testProtocol = new Protocol(
            "timeout",
            new DelayedProtocolSocketFactory(
                500,
                Protocol.getProtocol("http").getSocketFactory()
            ),
View Full Code Here


        // Append method name
        buf.append(name);
        buf.append(" ");
        // Absolute or relative URL?
        if (!connection.isTransparent()) {
            Protocol protocol = connection.getProtocol();
            buf.append(protocol.getScheme().toLowerCase());
            buf.append("://");
            buf.append(connection.getHost());
            if ((connection.getPort() != -1)
                && (connection.getPort() != protocol.getDefaultPort())
            ) {
                buf.append(":");
                buf.append(connection.getPort());
            }
        }
View Full Code Here

                this.action = "\"\"";
            }

            String host = this.url.getHost();
            int port = this.url.getPort();
            Protocol protocol = Protocol.getProtocol(this.url.getProtocol());

            if (System.getProperty("http.proxyHost") != null) {
                String proxyHost = System.getProperty("http.proxyHost");
                int proxyPort = Integer.parseInt(System.getProperty("http.proxyPort"));
                conn = new HttpConnection(proxyHost, proxyPort, host, null, port, protocol);
View Full Code Here

        if (scheme == null) {   // it may a URI instance or abs_path
            log.error("no scheme to start a session");
            throw new IllegalStateException("no scheme to start a session");
        }

        Protocol protocol = Protocol.getProtocol( scheme );

        String userinfo = uri.getUserinfo();
        if (userinfo != null) {
            getState().setCredentials(null,
                    new UsernamePasswordCredentials(userinfo));
View Full Code Here

     */
    public void startSession(URL url) {
        log.trace("enter HttpClient.startSession(String, int, Credentials, boolean)");

        int port = url.getPort();
        Protocol protocol = Protocol.getProtocol( url.getProtocol() );

        hostConfiguration.setHost(
            url.getHost(),
            port,
            protocol
View Full Code Here

    /**
     * @see org.apache.commons.httpclient.HttpConnectionManager#getConnection(HostConfiguration, long)
     */
    public HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout) {

        Protocol protocol = hostConfiguration.getProtocol();
        String host = hostConfiguration.getHost();
        int port = hostConfiguration.getPort();

        if ( httpConnection == null ) {

View Full Code Here

        return m_xInteractionHandler;
    }

    protected static Protocol GetOwnHttps( int nPort )
    {
        return new Protocol( "https", new WikiProtocolSocketFactory(), ( ( nPort < 0 ) ? 443 : nPort ) );
    }
View Full Code Here

    }

    if (isTrusted(host)) {
      // creating a special configuration that allows connections to non-trusted HTTPS hosts
      // see the javadoc to EasySSLProtocolSocketFactory for details
      Protocol easyHttps = new Protocol("https", (ProtocolSocketFactory)new EasySSLProtocolSocketFactory(), 443);
      HostConfiguration hc = new HostConfiguration();
      hc.setHost(host, 443, easyHttps);
      String relativeUri = new URI(uri.getPathQuery(), false).getURI();
      // it is important to use relative URI here, otherwise our custom protocol won't work.
      // we have to recreate the method, because HttpMethod#setUri won't overwrite the host,
View Full Code Here

   */
  private void configureClient() {

    // Set up an HTTPS socket factory that accepts self-signed certs.
    ProtocolSocketFactory factory = new SSLProtocolSocketFactory();
    Protocol https = new Protocol("https", factory, 443);
    Protocol.registerProtocol("https", https);

    HttpConnectionManagerParams params = connectionManager.getParams();
    params.setConnectionTimeout(timeout);
    params.setSoTimeout(timeout);
View Full Code Here

    public void testRedirectWithVirtualHost() throws IOException {
        String host = this.server.getLocalAddress();
        int port = this.server.getLocalPort();

        Protocol testhttp = new Protocol("http", new VirtualSocketFactory(host, port), port);
        Protocol.registerProtocol("testhttp", testhttp);
        try {
            this.server.setHttpService(new VirtualHostService());
            this.client.getHostConfiguration().setHost(host, port, "testhttp");
            this.client.getHostConfiguration().getParams().setVirtualHost("whatever.com");
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.protocol.Protocol

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.