Author: sjlee
Date: Mon Aug 4 11:50:39 2008
New Revision: 682462
URL: http://svn.apache.org/viewvc?rev=682462&view=rev
Log:
ASYNCWEB-22
Honor sessionCache even if proxy is enabled.
Modified:
mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/AsyncHttpClient.java
mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/codec/SessionCache.java
Modified:
mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/AsyncHttpClient.java
URL:
http://svn.apache.org/viewvc/mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/AsyncHttpClient.java?rev=682462&r1=682461&r2=682462&view=diff
==============================================================================
---
mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/AsyncHttpClient.java
(original)
+++
mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/AsyncHttpClient.java
Mon Aug 4 11:50:39 2008
@@ -505,7 +505,7 @@
// *IF* connection reuse is enabled, we should see if we have a cached
// connection first; if not, always open a new one
ConnectFuture future = null;
- if (!message.isProxyEnabled() && getSessionCache() != null) {
+ if (getSessionCache() != null) {
future = getCachedConnection(message);
} else {
// add the Connection close header explicitly
Modified:
mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/codec/SessionCache.java
URL:
http://svn.apache.org/viewvc/mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/codec/SessionCache.java?rev=682462&r1=682461&r2=682462&view=diff
==============================================================================
---
mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/codec/SessionCache.java
(original)
+++
mina/asyncweb/branches/1.0/client/src/main/java/org/apache/asyncweb/client/codec/SessionCache.java
Mon Aug 4 11:50:39 2008
@@ -25,6 +25,7 @@
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
+import org.apache.asyncweb.client.proxy.ProxyConfiguration;
import org.apache.mina.common.IoSession;
/**
@@ -59,7 +60,7 @@
IoSession cached = null;
while ((cached = queue.poll()) != null) {
- // see if the session is usable
+ // see if the session is usable
if (cached.isConnected() && !cached.isClosing()) {
return cached;
}
@@ -115,7 +116,14 @@
* @return A String key instance for this request.
*/
private String getKey(HttpRequestMessage msg) {
- return getKey(msg.getHost(), msg.getPort());
+ if (msg.isProxyEnabled()) {
+ ProxyConfiguration proxyCfg = msg.getProxyConfiguration();
+ return (msg.getProtocol().equalsIgnoreCase("https")) ?
+ getKey(proxyCfg.getHttpsProxyHost(),
proxyCfg.getHttpsProxyPort()) :
+ getKey(proxyCfg.getHttpProxyHost(),
proxyCfg.getHttpProxyPort());
+ } else {
+ return getKey(msg.getHost(), msg.getPort());
+ }
}
/**