Tab police

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@917639 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2010-03-01 18:39:29 +00:00
parent 26a75a8728
commit 47ffa72411
16 changed files with 205 additions and 205 deletions

View File

@ -34,15 +34,15 @@ import org.apache.http.params.HttpParams;
*
* @since 4.0
*/
public interface AuthSchemeFactory {
public interface AuthSchemeFactory {
/**
* Creates an instance of {@link AuthScheme} using given HTTP parameters.
*
* @param params HTTP parameters.
*
* @return auth scheme.
*/
/**
* Creates an instance of {@link AuthScheme} using given HTTP parameters.
*
* @param params HTTP parameters.
*
* @return auth scheme.
*/
AuthScheme newInstance(HttpParams params);
}

View File

@ -37,13 +37,13 @@ import java.net.InetAddress;
*/
public interface HostNameResolver {
/**
* Resolves given hostname to its IP address
*
* @param hostname the hostname.
* @return IP address.
* @throws IOException
*/
/**
* Resolves given hostname to its IP address
*
* @param hostname the hostname.
* @return IP address.
* @throws IOException
*/
InetAddress resolve (String hostname) throws IOException;
}

View File

@ -43,25 +43,25 @@ import java.security.cert.X509Certificate;
*/
public interface X509HostnameVerifier extends HostnameVerifier {
/**
* Verifies that the host name is an acceptable match with the server's
* authentication scheme based on the given {@link SSLSocket}.
*
* @param host the host.
* @param ssl the SSL socket.
* @throws IOException if an I/O error occurs or the verification process
* fails.
*/
/**
* Verifies that the host name is an acceptable match with the server's
* authentication scheme based on the given {@link SSLSocket}.
*
* @param host the host.
* @param ssl the SSL socket.
* @throws IOException if an I/O error occurs or the verification process
* fails.
*/
void verify(String host, SSLSocket ssl) throws IOException;
/**
* Verifies that the host name is an acceptable match with the server's
* authentication scheme based on the given {@link X509Certificate}.
*
* @param host the host.
* @param cert the certificate.
* @throws SSLException if the verification process fails.
*/
/**
* Verifies that the host name is an acceptable match with the server's
* authentication scheme based on the given {@link X509Certificate}.
*
* @param host the host.
* @param cert the certificate.
* @throws SSLException if the verification process fails.
*/
void verify(String host, X509Certificate cert) throws SSLException;
/**
@ -76,7 +76,7 @@ public interface X509HostnameVerifier extends HostnameVerifier {
* @param subjectAlts Subject-Alt fields of type 2 ("DNS"), as extracted
* from the X.509 certificate.
* @param host The hostname to verify.
* @throws SSLException if the verification process fails.
* @throws SSLException if the verification process fails.
*/
void verify(String host, String[] cns, String[] subjectAlts)
throws SSLException;

View File

@ -34,15 +34,15 @@ import org.apache.http.params.HttpParams;
*
* @since 4.0
*/
public interface CookieSpecFactory {
public interface CookieSpecFactory {
/**
* Creates an instance of {@link CookieSpec} using given HTTP parameters.
*
* @param params HTTP parameters.
*
* @return cookie spec.
*/
/**
* Creates an instance of {@link CookieSpec} using given HTTP parameters.
*
* @param params HTTP parameters.
*
* @return cookie spec.
*/
CookieSpec newInstance(HttpParams params);
}

View File

@ -82,13 +82,13 @@ public class DefaultClientConnection extends SocketHttpClientConnection
/** Whether this connection is secure. */
private boolean connSecure;
/** True if this connection was shutdown. */
private volatile boolean shutdown;
/** connection specific attributes */
private final Map<String, Object> attributes;
public DefaultClientConnection() {
super();
this.attributes = new HashMap<String, Object>();
@ -108,10 +108,10 @@ public class DefaultClientConnection extends SocketHttpClientConnection
}
public void opening(Socket sock, HttpHost target) throws IOException {
assertNotOpen();
assertNotOpen();
this.socket = sock;
this.targetHost = target;
// Check for shutdown after assigning socket, so that
if (this.shutdown) {
sock.close(); // allow this to throw...
@ -147,14 +147,14 @@ public class DefaultClientConnection extends SocketHttpClientConnection
public void shutdown() throws IOException {
log.debug("Connection shut down");
shutdown = true;
super.shutdown();
super.shutdown();
Socket sock = this.socket; // copy volatile attribute
if (sock != null)
sock.close();
}
@Override
public void close() throws IOException {
log.debug("Connection closed");
@ -231,10 +231,10 @@ public class DefaultClientConnection extends SocketHttpClientConnection
@Override
public HttpResponse receiveResponseHeader() throws HttpException, IOException {
HttpResponse response = super.receiveResponseHeader();
if (log.isDebugEnabled()) {
HttpResponse response = super.receiveResponseHeader();
if (log.isDebugEnabled()) {
log.debug("Receiving response: " + response.getStatusLine());
}
}
if (headerLog.isDebugEnabled()) {
headerLog.debug("<< " + response.getStatusLine().toString());
Header[] headers = response.getAllHeaders();
@ -247,9 +247,9 @@ public class DefaultClientConnection extends SocketHttpClientConnection
@Override
public void sendRequestHeader(HttpRequest request) throws HttpException, IOException {
if (log.isDebugEnabled()) {
if (log.isDebugEnabled()) {
log.debug("Sending request: " + request.getRequestLine());
}
}
super.sendRequestHeader(request);
if (headerLog.isDebugEnabled()) {
headerLog.debug(">> " + request.getRequestLine().toString());

View File

@ -64,7 +64,7 @@ import org.apache.http.util.CharArrayBuffer;
public class DefaultResponseParser extends AbstractMessageParser {
private final Log log = LogFactory.getLog(getClass());
private final HttpResponseFactory responseFactory;
private final CharArrayBuffer lineBuf;
private final int maxGarbageLines;
@ -110,7 +110,7 @@ public class DefaultResponseParser extends AbstractMessageParser {
"valid HTTP response");
}
if (this.log.isDebugEnabled()) {
this.log.debug("Garbage in response: " + this.lineBuf.toString());
this.log.debug("Garbage in response: " + this.lineBuf.toString());
}
count++;
} while(true);

View File

@ -54,17 +54,17 @@ public class BestMatchSpecFactory implements CookieSpecFactory {
public CookieSpec newInstance(final HttpParams params) {
if (params != null) {
String[] patterns = null;
Collection<?> param = (Collection<?>) params.getParameter(
CookieSpecPNames.DATE_PATTERNS);
if (param != null) {
patterns = new String[param.size()];
patterns = param.toArray(patterns);
}
boolean singleHeader = params.getBooleanParameter(
CookieSpecPNames.SINGLE_COOKIE_HEADER, false);
String[] patterns = null;
Collection<?> param = (Collection<?>) params.getParameter(
CookieSpecPNames.DATE_PATTERNS);
if (param != null) {
patterns = new String[param.size()];
patterns = param.toArray(patterns);
}
boolean singleHeader = params.getBooleanParameter(
CookieSpecPNames.SINGLE_COOKIE_HEADER, false);
return new BestMatchSpec(patterns, singleHeader);
} else {
return new BestMatchSpec();

View File

@ -53,14 +53,14 @@ public class BrowserCompatSpecFactory implements CookieSpecFactory {
public CookieSpec newInstance(final HttpParams params) {
if (params != null) {
String[] patterns = null;
Collection<?> param = (Collection<?>) params.getParameter(
CookieSpecPNames.DATE_PATTERNS);
if (param != null) {
patterns = new String[param.size()];
patterns = param.toArray(patterns);
}
String[] patterns = null;
Collection<?> param = (Collection<?>) params.getParameter(
CookieSpecPNames.DATE_PATTERNS);
if (param != null) {
patterns = new String[param.size()];
patterns = param.toArray(patterns);
}
return new BrowserCompatSpec(patterns);
} else {
return new BrowserCompatSpec();

View File

@ -67,8 +67,8 @@ public final class DateUtils {
public static final String PATTERN_ASCTIME = "EEE MMM d HH:mm:ss yyyy";
private static final String[] DEFAULT_PATTERNS = new String[] {
PATTERN_RFC1036,
PATTERN_RFC1123,
PATTERN_RFC1036,
PATTERN_RFC1123,
PATTERN_ASCTIME
};

View File

@ -49,18 +49,18 @@ import org.apache.http.params.HttpParams;
* @since 4.0
*/
@Immutable
public class NetscapeDraftSpecFactory implements CookieSpecFactory {
public class NetscapeDraftSpecFactory implements CookieSpecFactory {
public CookieSpec newInstance(final HttpParams params) {
if (params != null) {
String[] patterns = null;
Collection<?> param = (Collection<?>) params.getParameter(
CookieSpecPNames.DATE_PATTERNS);
if (param != null) {
patterns = new String[param.size()];
patterns = param.toArray(patterns);
}
String[] patterns = null;
Collection<?> param = (Collection<?>) params.getParameter(
CookieSpecPNames.DATE_PATTERNS);
if (param != null) {
patterns = new String[param.size()];
patterns = param.toArray(patterns);
}
return new NetscapeDraftSpec(patterns);
} else {
return new NetscapeDraftSpec();

View File

@ -50,21 +50,21 @@ import org.apache.http.params.HttpParams;
* @since 4.0
*/
@Immutable
public class RFC2109SpecFactory implements CookieSpecFactory {
public class RFC2109SpecFactory implements CookieSpecFactory {
public CookieSpec newInstance(final HttpParams params) {
if (params != null) {
String[] patterns = null;
Collection<?> param = (Collection<?>) params.getParameter(
CookieSpecPNames.DATE_PATTERNS);
if (param != null) {
patterns = new String[param.size()];
patterns = param.toArray(patterns);
}
boolean singleHeader = params.getBooleanParameter(
CookieSpecPNames.SINGLE_COOKIE_HEADER, false);
String[] patterns = null;
Collection<?> param = (Collection<?>) params.getParameter(
CookieSpecPNames.DATE_PATTERNS);
if (param != null) {
patterns = new String[param.size()];
patterns = param.toArray(patterns);
}
boolean singleHeader = params.getBooleanParameter(
CookieSpecPNames.SINGLE_COOKIE_HEADER, false);
return new RFC2109Spec(patterns, singleHeader);
} else {
return new RFC2109Spec();

View File

@ -50,21 +50,21 @@ import org.apache.http.params.HttpParams;
* @since 4.0
*/
@Immutable
public class RFC2965SpecFactory implements CookieSpecFactory {
public class RFC2965SpecFactory implements CookieSpecFactory {
public CookieSpec newInstance(final HttpParams params) {
if (params != null) {
String[] patterns = null;
Collection<?> param = (Collection<?>) params.getParameter(
CookieSpecPNames.DATE_PATTERNS);
if (param != null) {
patterns = new String[param.size()];
patterns = param.toArray(patterns);
}
boolean singleHeader = params.getBooleanParameter(
CookieSpecPNames.SINGLE_COOKIE_HEADER, false);
String[] patterns = null;
Collection<?> param = (Collection<?>) params.getParameter(
CookieSpecPNames.DATE_PATTERNS);
if (param != null) {
patterns = new String[param.size()];
patterns = param.toArray(patterns);
}
boolean singleHeader = params.getBooleanParameter(
CookieSpecPNames.SINGLE_COOKIE_HEADER, false);
return new RFC2965Spec(patterns, singleHeader);
} else {
return new RFC2965Spec();

View File

@ -47,7 +47,7 @@
<item name="Download" href="../download.html"/>
<item name="Examples" href="../examples.html"/>
</menu>
<menu ref="modules" />
<menu ref="reports"/>
<menu ref="modules" />
<menu ref="reports"/>
</body>
</project>

View File

@ -41,7 +41,7 @@ import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
public class TestURLEncodedUtils extends TestCase {
public TestURLEncodedUtils(final String testName) {
super(testName);
}
@ -54,7 +54,7 @@ public class TestURLEncodedUtils extends TestCase {
public static Test suite() {
return new TestSuite(TestURLEncodedUtils.class);
}
public void testParseURI () throws Exception {
List <NameValuePair> result;
@ -116,12 +116,12 @@ public class TestURLEncodedUtils extends TestCase {
static final int SWISS_GERMAN_HELLO [] = {
0x47, 0x72, 0xFC, 0x65, 0x7A, 0x69, 0x5F, 0x7A, 0xE4, 0x6D, 0xE4
};
static final int RUSSIAN_HELLO [] = {
0x412, 0x441, 0x435, 0x43C, 0x5F, 0x43F, 0x440, 0x438,
0x432, 0x435, 0x442
};
private static String constructString(int [] unicodeChars) {
StringBuffer buffer = new StringBuffer();
if (unicodeChars != null) {
@ -138,12 +138,12 @@ public class TestURLEncodedUtils extends TestCase {
List <NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("russian", ru_hello));
parameters.add(new BasicNameValuePair("swiss", ch_hello));
String s = URLEncodedUtils.format(parameters, HTTP.UTF_8);
assertEquals("russian=%D0%92%D1%81%D0%B5%D0%BC_%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82" +
"&swiss=Gr%C3%BCezi_z%C3%A4m%C3%A4", s);
"&swiss=Gr%C3%BCezi_z%C3%A4m%C3%A4", s);
StringEntity entity = new StringEntity(s, HTTP.UTF_8);
entity.setContentType(URLEncodedUtils.CONTENT_TYPE + HTTP.CHARSET_PARAM + HTTP.UTF_8);
List <NameValuePair> result = URLEncodedUtils.parse(entity);

View File

@ -62,98 +62,98 @@ public class TestDefaultResponseParser extends TestCase {
public static Test suite() {
return new TestSuite(TestDefaultResponseParser.class);
}
public void testResponseParsingWithSomeGarbage() throws Exception {
String s =
"garbage\r\n" +
"garbage\r\n" +
"more garbage\r\n" +
"HTTP/1.1 200 OK\r\n" +
"header1: value1\r\n" +
"header2: value2\r\n" +
"\r\n";
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
HttpResponse response = (HttpResponse) parser.parse();
assertNotNull(response);
assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
assertEquals(200, response.getStatusLine().getStatusCode());
Header[] headers = response.getAllHeaders();
assertNotNull(headers);
assertEquals(2, headers.length);
assertEquals("header1", headers[0].getName());
assertEquals("header2", headers[1].getName());
String s =
"garbage\r\n" +
"garbage\r\n" +
"more garbage\r\n" +
"HTTP/1.1 200 OK\r\n" +
"header1: value1\r\n" +
"header2: value2\r\n" +
"\r\n";
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
HttpResponse response = (HttpResponse) parser.parse();
assertNotNull(response);
assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
assertEquals(200, response.getStatusLine().getStatusCode());
Header[] headers = response.getAllHeaders();
assertNotNull(headers);
assertEquals(2, headers.length);
assertEquals("header1", headers[0].getName());
assertEquals("header2", headers[1].getName());
}
public void testResponseParsingWithTooMuchGarbage() throws Exception {
String s =
"garbage\r\n" +
"garbage\r\n" +
"more garbage\r\n" +
"HTTP/1.1 200 OK\r\n" +
"header1: value1\r\n" +
"header2: value2\r\n" +
"\r\n";
HttpParams params = new BasicHttpParams();
params.setParameter(ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE, Integer.valueOf(2));
SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
try {
parser.parse();
fail("ProtocolException should have been thrown");
} catch (ProtocolException ex) {
}
String s =
"garbage\r\n" +
"garbage\r\n" +
"more garbage\r\n" +
"HTTP/1.1 200 OK\r\n" +
"header1: value1\r\n" +
"header2: value2\r\n" +
"\r\n";
HttpParams params = new BasicHttpParams();
params.setParameter(ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE, Integer.valueOf(2));
SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
try {
parser.parse();
fail("ProtocolException should have been thrown");
} catch (ProtocolException ex) {
}
}
public void testResponseParsingNoResponse() throws Exception {
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuffer = new SessionInputBufferMockup("", "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
try {
parser.parse();
fail("NoHttpResponseException should have been thrown");
} catch (NoHttpResponseException ex) {
}
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuffer = new SessionInputBufferMockup("", "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
try {
parser.parse();
fail("NoHttpResponseException should have been thrown");
} catch (NoHttpResponseException ex) {
}
}
public void testResponseParsingOnlyGarbage() throws Exception {
String s =
"garbage\r\n" +
"garbage\r\n" +
"more garbage\r\n" +
"a lot more garbage\r\n";
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
try {
parser.parse();
fail("ProtocolException should have been thrown");
} catch (ProtocolException ex) {
}
String s =
"garbage\r\n" +
"garbage\r\n" +
"more garbage\r\n" +
"a lot more garbage\r\n";
HttpParams params = new BasicHttpParams();
SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
HttpMessageParser parser = new DefaultResponseParser(
inbuffer,
BasicLineParser.DEFAULT,
new DefaultHttpResponseFactory(),
params);
try {
parser.parse();
fail("ProtocolException should have been thrown");
} catch (ProtocolException ex) {
}
}
}

View File

@ -47,7 +47,7 @@
<item name="Download" href="../download.html"/>
<item name="Examples" href="../examples.html"/>
</menu>
<menu ref="modules" />
<menu ref="reports"/>
<menu ref="modules" />
<menu ref="reports"/>
</body>
</project>