HTTPCLIENT-1002: Stale connection check fails if wire logging is on

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1002956 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2010-09-30 07:35:30 +00:00
parent a2deba9de5
commit e5596fb025
1 changed files with 13 additions and 1 deletions

View File

@ -30,6 +30,7 @@ import java.io.IOException;
import org.apache.http.annotation.Immutable;
import org.apache.http.io.EofSensor;
import org.apache.http.io.HttpTransportMetrics;
import org.apache.http.io.SessionInputBuffer;
import org.apache.http.protocol.HTTP;
@ -42,11 +43,13 @@ import org.apache.http.util.CharArrayBuffer;
* @since 4.0
*/
@Immutable
public class LoggingSessionInputBuffer implements SessionInputBuffer {
public class LoggingSessionInputBuffer implements SessionInputBuffer, EofSensor {
/** Original session input buffer. */
private final SessionInputBuffer in;
private final EofSensor eofSensor;
/** The wire log to use for writing. */
private final Wire wire;
@ -62,6 +65,7 @@ public class LoggingSessionInputBuffer implements SessionInputBuffer {
final SessionInputBuffer in, final Wire wire, final String charset) {
super();
this.in = in;
this.eofSensor = in instanceof EofSensor ? (EofSensor) in : null;
this.wire = wire;
this.charset = charset != null ? charset : HTTP.ASCII;
}
@ -122,4 +126,12 @@ public class LoggingSessionInputBuffer implements SessionInputBuffer {
return this.in.getMetrics();
}
public boolean isEof() {
if (this.eofSensor != null) {
return this.eofSensor.isEof();
} else {
return false;
}
}
}