A little more work on the approach of wrapping the SessionInputBuffer, to remember that overriding BHttpConnectionBase.getSessionInputBuffer() makes it possible (but it doesn't work because we need to get in there and no-op the buffering since we do our own, and it eats up the stream too soon...)

This commit is contained in:
Noah Levitt
2012-12-28 18:46:39 -08:00
parent 33a500b213
commit 6300caf367
2 changed files with 29 additions and 25 deletions
@@ -101,6 +101,7 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.impl.conn.SocketClientConnectionImpl;
import org.apache.http.io.HttpMessageParserFactory;
import org.apache.http.io.HttpMessageWriterFactory;
import org.apache.http.io.SessionInputBuffer;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
@@ -149,11 +150,15 @@ public class FetchHTTP extends Processor implements Lifecycle {
super(buffersize, chardecoder, charencoder, constraints,
incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.inbuffer = new RecordingSessionInputBuffer(this.inbuffer);
this.request = request;
this.curi = curi;
}
@Override
protected SessionInputBuffer getSessionInputBuffer() {
return new RecordingSessionInputBuffer(super.getSessionInputBuffer());
}
@Override
protected InputStream getSocketInputStream(Socket socket)
throws IOException {
@@ -19,17 +19,16 @@
package org.archive.modules.fetcher;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.io.HttpTransportMetrics;
import org.apache.http.io.UmmSessionInputBuffer;
import org.apache.http.io.SessionInputBuffer;
import org.apache.http.util.CharArrayBuffer;
class RecordingSessionInputBuffer implements UmmSessionInputBuffer {
class RecordingSessionInputBuffer implements SessionInputBuffer {
protected UmmSessionInputBuffer wrapped;
protected SessionInputBuffer wrapped;
public RecordingSessionInputBuffer(UmmSessionInputBuffer wrapped) {
public RecordingSessionInputBuffer(SessionInputBuffer wrapped) {
this.wrapped = wrapped;
}
@@ -69,23 +68,23 @@ class RecordingSessionInputBuffer implements UmmSessionInputBuffer {
return wrapped.getMetrics();
}
@Override
public boolean isBound() {
return wrapped.isBound();
}
@Override
public void bind(InputStream inputStream) {
wrapped.bind(inputStream);
}
@Override
public boolean hasBufferedData() {
return wrapped.hasBufferedData();
}
@Override
public int fillBuffer() throws IOException {
return wrapped.fillBuffer();
}
// @Override
// public boolean isBound() {
// return wrapped.isBound();
// }
//
// @Override
// public void bind(InputStream inputStream) {
// wrapped.bind(inputStream);
// }
//
// @Override
// public boolean hasBufferedData() {
// return wrapped.hasBufferedData();
// }
//
// @Override
// public int fillBuffer() throws IOException {
// return wrapped.fillBuffer();
// }
}