hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r169874 - in /jakarta/httpclient/trunk/http-common/src/java/org/apache/http: HttpProxyConnection.java impl/DefaultHttpProxyConnection.java
Date Thu, 12 May 2005 19:25:42 GMT
Author: olegk
Date: Thu May 12 12:25:41 2005
New Revision: 169874

URL: http://svn.apache.org/viewcvs?rev=169874&view=rev
Log:
Added HttpProxyConnection and its default impl

Added:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpProxyConnection.java
  (with props)
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java
  (with props)

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpProxyConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpProxyConnection.java?rev=169874&view=auto
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpProxyConnection.java
(added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpProxyConnection.java
Thu May 12 12:25:41 2005
@@ -0,0 +1,55 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  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
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  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 implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http;
+
+import java.io.IOException;
+
+import org.apache.http.params.HttpParams;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public interface HttpProxyConnection extends HttpClientConnection {
+
+    void tunnelTo(HttpHost targetHost, HttpParams params) throws IOException;
+    
+    HttpHost getTunnelTarget();
+    
+    boolean isTunnelActive();
+
+    boolean isSecure();
+    
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpProxyConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpProxyConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpProxyConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java?rev=169874&view=auto
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java
(added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java
Thu May 12 12:25:41 2005
@@ -0,0 +1,114 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  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
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  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 implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+
+import org.apache.http.HttpHost;
+import org.apache.http.HttpProxyConnection;
+import org.apache.http.Protocol;
+import org.apache.http.ProtocolSocketFactory;
+import org.apache.http.ProxyHost;
+import org.apache.http.SecureProtocolSocketFactory;
+import org.apache.http.params.HttpParams;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public class DefaultHttpProxyConnection 
+        extends DefaultHttpClientConnection implements HttpProxyConnection {
+
+    private volatile HttpHost tunneltarget = null;
+    private volatile boolean secure = false;
+    
+    public DefaultHttpProxyConnection(final ProxyHost proxyhost, final InetAddress localAddress)
{
+        super(proxyhost, localAddress);
+    }
+    
+    public DefaultHttpProxyConnection(final ProxyHost proxyhost) {
+        this(proxyhost, null);
+    }
+
+    public void close() throws IOException {
+        this.tunneltarget = null;
+        this.secure = false;
+        super.close();
+    }
+    
+    public void tunnelTo(final HttpHost targetHost, final HttpParams params) 
+            throws IOException {
+        if (targetHost == null) {
+            throw new IllegalArgumentException("Target host may not be null");
+        }
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        if (this.tunneltarget != null) {
+            throw new IllegalStateException("Secure tunnel to " + 
+                    this.tunneltarget + " is already active");
+        }
+        assertOpen();
+        Protocol protocol = targetHost.getProtocol();
+        ProtocolSocketFactory socketfactory = protocol.getSocketFactory();
+        if (socketfactory instanceof SecureProtocolSocketFactory) {
+            Socket socket = ((SecureProtocolSocketFactory)socketfactory)
+                .createSocket(
+                    this.socket, 
+                    targetHost.getHostName(), 
+                    targetHost.getPort(), 
+                    true);
+            bind(socket, params);
+            this.secure = true;
+        } else {
+            this.secure = false;
+        }
+        this.tunneltarget = targetHost;
+    }
+    
+    public HttpHost getTunnelTarget() {
+        return this.tunneltarget;
+    }
+    
+    public boolean isTunnelActive() {
+        return this.tunneltarget != null;
+    }
+    
+    public boolean isSecure() {
+        return this.secure;
+    }
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/DefaultHttpProxyConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message