1 package org.apache.commons.httpclient.contrib.ssl; 2 3 import org.apache.commons.httpclient.HostConfiguration; 4 import org.apache.commons.httpclient.HttpHost; 5 import org.apache.commons.httpclient.protocol.Protocol; 6 7 27 public class HostConfigurationWithStickyProtocol extends HostConfiguration 28 { 29 public HostConfigurationWithStickyProtocol() 30 { 31 } 32 33 public HostConfigurationWithStickyProtocol(HostConfiguration hostConfiguration) 34 { 35 super(hostConfiguration); 36 } 37 38 public Object clone() 39 { 40 return new HostConfigurationWithStickyProtocol(this); 41 } 42 43 public synchronized void setHost(String host, int port, String scheme) 44 { 45 setHost(new HttpHost(host, port, getNewProtocol(host, port, scheme))); 46 } 47 48 56 protected Protocol getNewProtocol(String host, int port, String scheme) 57 { 58 final Protocol oldProtocol = getProtocol(); 59 if (oldProtocol != null) { 60 final String oldScheme = oldProtocol.getScheme(); 61 if (oldScheme == scheme || (oldScheme != null && oldScheme.equalsIgnoreCase(scheme))) { 62 return oldProtocol; } 65 } 66 return Protocol.getProtocol(scheme); 67 } 68 69 } 70 | Popular Tags |