in httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java [93:176]
public ClientHttp1StreamDuplexer(
final ProtocolIOSession ioSession,
final HttpProcessor httpProcessor,
final Http1Config http1Config,
final CharCodingConfig charCodingConfig,
final ConnectionReuseStrategy connectionReuseStrategy,
final NHttpMessageParser<HttpResponse> incomingMessageParser,
final NHttpMessageWriter<HttpRequest> outgoingMessageWriter,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final Http1StreamListener streamListener) {
super(ioSession, http1Config, charCodingConfig, incomingMessageParser, outgoingMessageWriter,
incomingContentStrategy, outgoingContentStrategy);
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.http1Config = http1Config != null ? http1Config : Http1Config.DEFAULT;
this.connectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy :
DefaultConnectionReuseStrategy.INSTANCE;
this.streamListener = streamListener;
this.pipeline = new ConcurrentLinkedQueue<>();
this.outputChannel = new Http1StreamChannel<HttpRequest>() {
@Override
public void close() {
shutdownSession(CloseMode.IMMEDIATE);
}
@Override
public void submit(
final HttpRequest request,
final boolean endStream,
final FlushMode flushMode) throws HttpException, IOException {
if (streamListener != null) {
streamListener.onRequestHead(ClientHttp1StreamDuplexer.this, request);
}
commitMessageHead(request, endStream, flushMode);
}
@Override
public void suspendOutput() throws IOException {
suspendSessionOutput();
}
@Override
public void requestOutput() {
requestSessionOutput();
}
@Override
public Timeout getSocketTimeout() {
return getSessionTimeout();
}
@Override
public void setSocketTimeout(final Timeout timeout) {
setSessionTimeout(timeout);
}
@Override
public int write(final ByteBuffer src) throws IOException {
return streamOutput(src);
}
@Override
public void complete(final List<? extends Header> trailers) throws IOException {
endOutputStream(trailers);
}
@Override
public boolean isCompleted() {
return isOutputCompleted();
}
@Override
public boolean abortGracefully() throws IOException {
final MessageDelineation messageDelineation = endOutputStream(null);
return messageDelineation != MessageDelineation.MESSAGE_HEAD;
}
@Override
public void activate() throws HttpException, IOException {
}
};
}