418 synchronized void setSingleStream(boolean use) { |
418 synchronized void setSingleStream(boolean use) { |
419 singleStream = use; |
419 singleStream = use; |
420 } |
420 } |
421 |
421 |
422 static String keyFor(HttpConnection connection) { |
422 static String keyFor(HttpConnection connection) { |
423 boolean isProxy = connection.isProxied(); |
423 boolean isProxy = connection.isProxied(); // tunnel or plain clear connection through proxy |
424 boolean isSecure = connection.isSecure(); |
424 boolean isSecure = connection.isSecure(); |
425 InetSocketAddress addr = connection.address(); |
425 InetSocketAddress addr = connection.address(); |
426 |
426 |
427 return keyString(isSecure, isProxy, addr.getHostString(), addr.getPort()); |
427 return keyString(isSecure, isProxy, addr.getHostString(), addr.getPort()); |
428 } |
428 } |
429 |
429 |
430 static String keyFor(URI uri, InetSocketAddress proxy) { |
430 static String keyFor(URI uri, InetSocketAddress proxy) { |
431 boolean isSecure = uri.getScheme().equalsIgnoreCase("https"); |
431 boolean isSecure = uri.getScheme().equalsIgnoreCase("https"); |
432 boolean isProxy = proxy != null; |
432 boolean isProxy = proxy != null; |
433 |
433 |
434 String host; |
434 String host; |
435 int port; |
435 int port; |
436 |
436 |
437 if (proxy != null) { |
437 if (proxy != null && !isSecure) { |
|
438 // clear connection through proxy: use |
|
439 // proxy host / proxy port |
438 host = proxy.getHostString(); |
440 host = proxy.getHostString(); |
439 port = proxy.getPort(); |
441 port = proxy.getPort(); |
440 } else { |
442 } else { |
|
443 // either secure tunnel connection through proxy |
|
444 // or direct connection to host, but in either |
|
445 // case only that host can be reached through |
|
446 // the connection: use target host / target port |
441 host = uri.getHost(); |
447 host = uri.getHost(); |
442 port = uri.getPort(); |
448 port = uri.getPort(); |
443 } |
449 } |
444 return keyString(isSecure, isProxy, host, port); |
450 return keyString(isSecure, isProxy, host, port); |
445 } |
451 } |