You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2006/11/21 20:54:53 UTC

svn commit: r477852 - in /jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http: HttpInetConnection.java impl/SocketHttpClientConnection.java impl/SocketHttpServerConnection.java

Author: olegk
Date: Tue Nov 21 11:54:52 2006
New Revision: 477852

URL: http://svn.apache.org/viewvc?view=rev&rev=477852
Log:
HTTPCORE-15: Added an interface that represents an HTTP connection over Internet Protocol

Added:
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpInetConnection.java   (with props)
Modified:
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java

Added: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpInetConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpInetConnection.java?view=auto&rev=477852
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpInetConnection.java (added)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpInetConnection.java Tue Nov 21 11:54:52 2006
@@ -0,0 +1,49 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2006 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.net.InetAddress;
+
+/**
+ * An HTTP connection over the Internet Protocol (IP).
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public interface HttpInetConnection extends HttpConnection {
+
+    InetAddress getLocalAddress();
+
+    InetAddress getRemoteAddress();
+    
+}

Propchange: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpInetConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpInetConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java?view=diff&rev=477852&r1=477851&r2=477852
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java Tue Nov 21 11:54:52 2006
@@ -30,8 +30,10 @@
 package org.apache.http.impl;
 
 import java.io.IOException;
+import java.net.InetAddress;
 import java.net.Socket;
 
+import org.apache.http.HttpInetConnection;
 import org.apache.http.impl.io.SocketHttpDataReceiver;
 import org.apache.http.impl.io.SocketHttpDataTransmitter;
 import org.apache.http.io.HttpDataReceiver;
@@ -49,7 +51,8 @@
  * 
  * @since 4.0
  */
-public class SocketHttpClientConnection extends AbstractHttpClientConnection {
+public class SocketHttpClientConnection 
+        extends AbstractHttpClientConnection implements HttpInetConnection {
 
     protected volatile boolean open;
     protected Socket socket = null;
@@ -106,6 +109,22 @@
 
     public boolean isOpen() {
         return this.open;
+    }
+
+    public InetAddress getLocalAddress() {
+        if (this.socket != null) {
+            return this.socket.getLocalAddress();
+        } else {
+            return null;
+        }
+    }
+
+    public InetAddress getRemoteAddress() {
+        if (this.socket != null) {
+            return this.socket.getInetAddress();
+        } else {
+            return null;
+        }
     }
 
     public void shutdown() throws IOException {

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java?view=diff&rev=477852&r1=477851&r2=477852
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java Tue Nov 21 11:54:52 2006
@@ -30,8 +30,10 @@
 package org.apache.http.impl;
 
 import java.io.IOException;
+import java.net.InetAddress;
 import java.net.Socket;
 
+import org.apache.http.HttpInetConnection;
 import org.apache.http.impl.io.SocketHttpDataReceiver;
 import org.apache.http.impl.io.SocketHttpDataTransmitter;
 import org.apache.http.io.HttpDataReceiver;
@@ -49,7 +51,8 @@
  * 
  * @since 4.0
  */
-public class SocketHttpServerConnection extends AbstractHttpServerConnection {
+public class SocketHttpServerConnection extends 
+        AbstractHttpServerConnection implements HttpInetConnection {
 
     protected volatile boolean open;
     protected Socket socket = null;
@@ -104,6 +107,22 @@
 
     public boolean isOpen() {
         return this.open;
+    }
+
+    public InetAddress getLocalAddress() {
+        if (this.socket != null) {
+            return this.socket.getLocalAddress();
+        } else {
+            return null;
+        }
+    }
+
+    public InetAddress getRemoteAddress() {
+        if (this.socket != null) {
+            return this.socket.getInetAddress();
+        } else {
+            return null;
+        }
     }
 
     public void shutdown() throws IOException {