HTTPCORE-110, adjustment to API changes
git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@568003 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
532fddb7aa
commit
d815670db3
|
@ -43,6 +43,7 @@ import org.apache.http.HttpHost;
|
|||
import org.apache.http.HttpRequest;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpResponseFactory;
|
||||
import org.apache.http.message.LineParser;
|
||||
import org.apache.http.params.HttpParams;
|
||||
import org.apache.http.impl.SocketHttpClientConnection;
|
||||
import org.apache.http.io.HttpMessageParser;
|
||||
|
@ -80,6 +81,8 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
/** Whether this connection is secure. */
|
||||
private boolean connSecure;
|
||||
|
||||
/** The line parser to use, or <code>null</code> for the default parser. */
|
||||
private LineParser lineParser;
|
||||
|
||||
|
||||
// public default constructor
|
||||
|
@ -131,6 +134,26 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
|
||||
} // shutdown
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the line parser to be used for receiving messages.
|
||||
*
|
||||
* @return the line parser, or <code>null</code> for the default
|
||||
*/
|
||||
public LineParser getParser() {
|
||||
return lineParser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the line parser to use when receiving messages.
|
||||
*
|
||||
* @param parser the line parser to use, or
|
||||
* <code>null</code> for the default
|
||||
*/
|
||||
public final void setParser(LineParser parser) {
|
||||
lineParser = parser;
|
||||
}
|
||||
|
||||
|
||||
public void close() throws IOException {
|
||||
LOG.debug("Connection closed");
|
||||
|
@ -172,7 +195,8 @@ public class DefaultClientConnection extends SocketHttpClientConnection
|
|||
final SessionInputBuffer buffer,
|
||||
final HttpResponseFactory responseFactory,
|
||||
final HttpParams params) {
|
||||
return new DefaultResponseParser(buffer, responseFactory, params);
|
||||
return new DefaultResponseParser
|
||||
(buffer, lineParser, responseFactory, params);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.net.Socket;
|
|||
import java.net.InetAddress;
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.message.LineParser;
|
||||
import org.apache.http.params.HttpParams;
|
||||
import org.apache.http.params.HttpConnectionParams;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
|
@ -69,6 +70,12 @@ public class DefaultClientConnectionOperator
|
|||
/** The scheme registry for looking up socket factories. */
|
||||
protected SchemeRegistry schemeRegistry;
|
||||
|
||||
/**
|
||||
* The line parser to use for created connections.
|
||||
* <code>null</code> indicates the default parser.
|
||||
*/
|
||||
protected LineParser lineParser;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new client connection operator for the given scheme registry.
|
||||
|
@ -84,9 +91,31 @@ public class DefaultClientConnectionOperator
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the line parser to be used by the connections.
|
||||
*
|
||||
* @return the line parser, or <code>null</code> for the default
|
||||
*/
|
||||
public LineParser getParser() {
|
||||
return lineParser;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specifies the line parser to be used by the connections.
|
||||
*
|
||||
* @param parser the line parser, or <code>null</code> for the default
|
||||
*/
|
||||
public void setParser(LineParser parser) {
|
||||
lineParser = parser;
|
||||
}
|
||||
|
||||
|
||||
// non-javadoc, see interface ClientConnectionOperator
|
||||
public OperatedClientConnection createConnection() {
|
||||
return new DefaultClientConnection();
|
||||
DefaultClientConnection dcc = new DefaultClientConnection();
|
||||
dcc.setParser(lineParser);
|
||||
return dcc;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,8 @@ import org.apache.http.StatusLine;
|
|||
import org.apache.http.conn.params.HttpConnectionManagerParams;
|
||||
import org.apache.http.impl.io.AbstractMessageParser;
|
||||
import org.apache.http.io.SessionInputBuffer;
|
||||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.apache.http.message.LineParser;
|
||||
//@@@ import org.apache.http.message.BasicStatusLine;
|
||||
import org.apache.http.params.HttpParams;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
import org.apache.http.util.CharArrayBuffer;
|
||||
|
@ -55,11 +56,13 @@ public class DefaultResponseParser extends AbstractMessageParser {
|
|||
|
||||
public DefaultResponseParser(
|
||||
final SessionInputBuffer buffer,
|
||||
final LineParser parser,
|
||||
final HttpResponseFactory responseFactory,
|
||||
final HttpParams params) {
|
||||
super(buffer, params);
|
||||
super(buffer, parser, params);
|
||||
if (responseFactory == null) {
|
||||
throw new IllegalArgumentException("Response factory may not be null");
|
||||
throw new IllegalArgumentException
|
||||
("Response factory may not be null");
|
||||
}
|
||||
this.responseFactory = responseFactory;
|
||||
this.lineBuf = new CharArrayBuffer(128);
|
||||
|
@ -111,7 +114,7 @@ public class DefaultResponseParser extends AbstractMessageParser {
|
|||
count++;
|
||||
} while(true);
|
||||
//create the status line from the status string
|
||||
StatusLine statusline = BasicStatusLine.parse(this.lineBuf, 0, this.lineBuf.length());
|
||||
StatusLine statusline = lineParser.parseStatusLine(this.lineBuf, 0, this.lineBuf.length());
|
||||
return this.responseFactory.newHttpResponse(statusline, null);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue