Deprecated ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1098106 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2011-04-30 12:42:44 +00:00
parent 4998e3562d
commit 471c2b3ae9
4 changed files with 26 additions and 7 deletions

View File

@ -26,11 +26,14 @@
package org.apache.http.conn.params;
import org.apache.http.impl.conn.DefaultResponseParser;
/**
* Parameter names for HTTP client connections.
*
* @since 4.0
*/
@Deprecated
public interface ConnConnectionPNames {
/**
@ -49,6 +52,8 @@ public interface ConnConnectionPNames {
* 0 disallows all garbage/empty lines before the status line.
* Use {@link java.lang.Integer#MAX_VALUE} for unlimited number.
* </p>
*
* @deprecated Use custom {@link DefaultResponseParser} implementation
*/
public static final String MAX_STATUS_LINE_GARBAGE = "http.connection.max-status-line-garbage";

View File

@ -29,6 +29,7 @@ package org.apache.http.conn.params;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.impl.conn.DefaultResponseParser;
import org.apache.http.params.HttpAbstractParamBean;
import org.apache.http.params.HttpParams;
@ -40,6 +41,7 @@ import org.apache.http.params.HttpParams;
* @since 4.0
*/
@NotThreadSafe
@Deprecated
public class ConnConnectionParamBean extends HttpAbstractParamBean {
public ConnConnectionParamBean (final HttpParams params) {
@ -47,7 +49,7 @@ public class ConnConnectionParamBean extends HttpAbstractParamBean {
}
/**
* @see ConnConnectionPNames#MAX_STATUS_LINE_GARBAGE
* @deprecated Use custom {@link DefaultResponseParser} implementation
*/
public void setMaxStatusLineGarbage (final int maxStatusLineGarbage) {
params.setIntParameter(ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE, maxStatusLineGarbage);

View File

@ -39,7 +39,6 @@ import org.apache.http.HttpResponseFactory;
import org.apache.http.NoHttpResponseException;
import org.apache.http.ProtocolException;
import org.apache.http.StatusLine;
import org.apache.http.conn.params.ConnConnectionPNames;
import org.apache.http.impl.io.AbstractMessageParser;
import org.apache.http.io.SessionInputBuffer;
import org.apache.http.message.LineParser;
@ -81,10 +80,18 @@ public class DefaultResponseParser extends AbstractMessageParser {
}
this.responseFactory = responseFactory;
this.lineBuf = new CharArrayBuffer(128);
this.maxGarbageLines = params.getIntParameter(
ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE, Integer.MAX_VALUE);
this.maxGarbageLines = getMaxGarbageLines(params);
}
/**
* @since 4.2
*/
@SuppressWarnings("deprecation")
protected int getMaxGarbageLines(final HttpParams params) {
return params.getIntParameter(
org.apache.http.conn.params.ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE,
Integer.MAX_VALUE);
}
@Override
protected HttpMessage parseHead(

View File

@ -32,7 +32,6 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.NoHttpResponseException;
import org.apache.http.ProtocolException;
import org.apache.http.conn.params.ConnConnectionPNames;
import org.apache.http.impl.DefaultHttpResponseFactory;
import org.apache.http.io.HttpMessageParser;
import org.apache.http.io.SessionInputBuffer;
@ -91,13 +90,19 @@ public class TestDefaultResponseParser {
"\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);
params) {
@Override
protected int getMaxGarbageLines(HttpParams params) {
return 2;
}
};
parser.parse();
}