mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-11-24 14:26:09 +03:00
quic: Add support for HTTP/3 CONNECT Fast Open
This commit is contained in:
parent
af463205cb
commit
95d1c8d79c
@ -38,6 +38,10 @@ QuicProxyClientSocket::QuicProxyClientSocket(
|
|||||||
auth_(auth_controller),
|
auth_(auth_controller),
|
||||||
user_agent_(user_agent),
|
user_agent_(user_agent),
|
||||||
redirect_has_load_timing_info_(false),
|
redirect_has_load_timing_info_(false),
|
||||||
|
// This is a hack to avoid messing up higer APIs.
|
||||||
|
// Should be false by default officially.
|
||||||
|
use_fastopen_(true),
|
||||||
|
read_headers_pending_(false),
|
||||||
net_log_(net_log),
|
net_log_(net_log),
|
||||||
weak_factory_(this) {
|
weak_factory_(this) {
|
||||||
DCHECK(stream_->IsOpen());
|
DCHECK(stream_->IsOpen());
|
||||||
@ -309,6 +313,20 @@ int QuicProxyClientSocket::DoLoop(int last_io_result) {
|
|||||||
rv = DoReadReplyComplete(rv);
|
rv = DoReadReplyComplete(rv);
|
||||||
net_log_.EndEventWithNetErrorCode(
|
net_log_.EndEventWithNetErrorCode(
|
||||||
NetLogEventType::HTTP_TRANSACTION_TUNNEL_READ_HEADERS, rv);
|
NetLogEventType::HTTP_TRANSACTION_TUNNEL_READ_HEADERS, rv);
|
||||||
|
if (use_fastopen_ && read_headers_pending_) {
|
||||||
|
read_headers_pending_ = false;
|
||||||
|
if (rv < 0) {
|
||||||
|
// read_callback_ cannot be called.
|
||||||
|
if (!read_callback_)
|
||||||
|
rv = ERR_IO_PENDING;
|
||||||
|
// read_callback_ will be called with this error and be reset.
|
||||||
|
// Further data after that will be ignored.
|
||||||
|
next_state_ = STATE_DISCONNECTED;
|
||||||
|
} else {
|
||||||
|
// Does not call read_callback_ from here if headers are OK.
|
||||||
|
rv = ERR_IO_PENDING;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
NOTREACHED() << "bad state";
|
NOTREACHED() << "bad state";
|
||||||
@ -382,6 +400,11 @@ int QuicProxyClientSocket::DoReadReply() {
|
|||||||
&response_header_block_,
|
&response_header_block_,
|
||||||
base::Bind(&QuicProxyClientSocket::OnReadResponseHeadersComplete,
|
base::Bind(&QuicProxyClientSocket::OnReadResponseHeadersComplete,
|
||||||
weak_factory_.GetWeakPtr()));
|
weak_factory_.GetWeakPtr()));
|
||||||
|
if (use_fastopen_ && rv == ERR_IO_PENDING) {
|
||||||
|
read_headers_pending_ = true;
|
||||||
|
next_state_ = STATE_CONNECT_COMPLETE;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
if (rv == ERR_IO_PENDING)
|
if (rv == ERR_IO_PENDING)
|
||||||
return ERR_IO_PENDING;
|
return ERR_IO_PENDING;
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
@ -431,6 +454,11 @@ int QuicProxyClientSocket::DoReadReplyComplete(int result) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QuicProxyClientSocket::OnReadResponseHeadersComplete(int result) {
|
void QuicProxyClientSocket::OnReadResponseHeadersComplete(int result) {
|
||||||
|
if (use_fastopen_ && read_headers_pending_ &&
|
||||||
|
next_state_ == STATE_CONNECT_COMPLETE) {
|
||||||
|
next_state_ = STATE_READ_REPLY_COMPLETE;
|
||||||
|
}
|
||||||
|
|
||||||
// Convert the now-populated spdy::SpdyHeaderBlock to HttpResponseInfo
|
// Convert the now-populated spdy::SpdyHeaderBlock to HttpResponseInfo
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
result = ProcessResponseHeaders(response_header_block_);
|
result = ProcessResponseHeaders(response_header_block_);
|
||||||
|
@ -147,6 +147,9 @@ class NET_EXPORT_PRIVATE QuicProxyClientSocket : public ProxyClientSocket {
|
|||||||
// Session connect timing info.
|
// Session connect timing info.
|
||||||
LoadTimingInfo::ConnectTiming connect_timing_;
|
LoadTimingInfo::ConnectTiming connect_timing_;
|
||||||
|
|
||||||
|
bool use_fastopen_;
|
||||||
|
bool read_headers_pending_;
|
||||||
|
|
||||||
const NetLogWithSource net_log_;
|
const NetLogWithSource net_log_;
|
||||||
|
|
||||||
// The default weak pointer factory.
|
// The default weak pointer factory.
|
||||||
|
Loading…
Reference in New Issue
Block a user