Skip to content

Commit

Permalink
Tweaked OperatedClientConnection interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ok2c committed Sep 10, 2011
1 parent 62e1da7 commit 60737d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.apache.http.nio.reactor.IOSession;
import org.apache.http.nio.reactor.SessionInputBuffer;
import org.apache.http.nio.reactor.SessionOutputBuffer;
import org.apache.http.nio.reactor.ssl.SSLIOSession;
import org.apache.http.nio.util.ByteBufferAllocator;
import org.apache.http.params.HttpParams;

Expand All @@ -55,7 +54,6 @@ public class DefaultClientConnection
private final Log log;

private String id;
private SSLIOSession ssliosession;

public DefaultClientConnection(
final String id,
Expand All @@ -69,11 +67,6 @@ public DefaultClientConnection(
if (this.log.isDebugEnabled() || this.wirelog.isDebugEnabled()) {
this.session = new LoggingIOSession(iosession, this.id, this.log, this.wirelog);
}
if (iosession instanceof SSLIOSession) {
this.ssliosession = (SSLIOSession) iosession;
} else {
this.ssliosession = null;
}
}

public void upgrade(final IOSession iosession) {
Expand All @@ -85,15 +78,10 @@ public void upgrade(final IOSession iosession) {
this.session = iosession;
}
this.session.setBufferStatus(this);
if (iosession instanceof SSLIOSession) {
this.ssliosession = (SSLIOSession) iosession;
} else {
this.ssliosession = null;
}
}

public SSLIOSession getSSLIOSession() {
return this.ssliosession;
public IOSession getIOSession() {
return this.session;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public void resetInput() {

public boolean isSecure() {
OperatedClientConnection conn = ensureConnection();
return conn.getSSLIOSession() != null;
return conn.getIOSession() instanceof SSLIOSession;
}

public HttpRoute getRoute() {
Expand All @@ -248,8 +248,12 @@ public HttpRoute getRoute() {

public SSLSession getSSLSession() {
OperatedClientConnection conn = ensureConnection();
SSLIOSession iosession = conn.getSSLIOSession();
return iosession != null ? iosession.getSSLSession() : null;
IOSession iosession = conn.getIOSession();
if (iosession instanceof SSLIOSession) {
return ((SSLIOSession) iosession).getSSLSession();
} else {
return null;
}
}

public Object getState() {
Expand Down Expand Up @@ -320,7 +324,7 @@ public synchronized void open(
iosession.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);

if (proxy == null) {
tracker.connectTarget(conn.getSSLIOSession() != null);
tracker.connectTarget(conn.getIOSession() instanceof SSLIOSession);
} else {
tracker.connectProxy(proxy, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
import org.apache.http.nio.NHttpClientConnection;
import org.apache.http.nio.NHttpClientIOTarget;
import org.apache.http.nio.reactor.IOSession;
import org.apache.http.nio.reactor.ssl.SSLIOSession;

public interface OperatedClientConnection
extends NHttpClientConnection, HttpInetConnection, NHttpClientIOTarget {

void upgrade(IOSession iosession);

SSLIOSession getSSLIOSession();
IOSession getIOSession();

}

0 comments on commit 60737d5

Please sign in to comment.