This is an automated email from the ASF dual-hosted git repository. cmcfarlen pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit d056e07dd95c230e9e57b9f7b3bde83025744999 Author: Masakazu Kitajo <[email protected]> AuthorDate: Mon Feb 19 09:22:12 2024 -0700 http3: Don't use chunked encoding unnecessarily (#11080) (cherry picked from commit fc3fd98d106d5073c9668d1e18e5b8527a599324) --- include/iocore/net/quic/QUICStream.h | 2 ++ src/iocore/net/quic/QUICStream.cc | 7 +++++++ src/proxy/http3/Http3Transaction.cc | 11 +++++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/iocore/net/quic/QUICStream.h b/include/iocore/net/quic/QUICStream.h index 29283d71a0..2280ecdecb 100644 --- a/include/iocore/net/quic/QUICStream.h +++ b/include/iocore/net/quic/QUICStream.h @@ -51,6 +51,7 @@ public: const QUICConnectionInfoProvider *connection_info(); QUICStreamDirection direction() const; bool is_bidirectional() const; + bool has_no_more_data() const; QUICOffset final_offset() const; @@ -82,6 +83,7 @@ protected: QUICStreamAdapter *_adapter = nullptr; uint64_t _received_bytes = 0; uint64_t _sent_bytes = 0; + bool _has_no_more_data = false; }; class QUICStreamStateListener diff --git a/src/iocore/net/quic/QUICStream.cc b/src/iocore/net/quic/QUICStream.cc index a7241ada28..c911274632 100644 --- a/src/iocore/net/quic/QUICStream.cc +++ b/src/iocore/net/quic/QUICStream.cc @@ -55,6 +55,12 @@ QUICStream::is_bidirectional() const return ((this->_id & 0x03) < 0x02); } +bool +QUICStream::has_no_more_data() const +{ + return this->_has_no_more_data; +} + void QUICStream::set_io_adapter(QUICStreamAdapter *adapter) { @@ -98,6 +104,7 @@ QUICStream::receive_data(quiche_conn *quiche_con) this->_adapter->write(this->_received_bytes, buf, read_len, fin); this->_received_bytes += read_len; } + this->_has_no_more_data = quiche_conn_stream_finished(quiche_con, this->_id); this->_adapter->encourge_read(); } diff --git a/src/proxy/http3/Http3Transaction.cc b/src/proxy/http3/Http3Transaction.cc index 11ce096ebd..a2c96ec23a 100644 --- a/src/proxy/http3/Http3Transaction.cc +++ b/src/proxy/http3/Http3Transaction.cc @@ -617,8 +617,8 @@ Http3Transaction::_process_write_vio() bool Http3Transaction::has_request_body(int64_t content_length, bool is_chunked_set) const { - // Has body if Content-Length != 0 - if (content_length != 0) { + // Has body if Content-Length != 0 (content_length can be -1 if it's undefined) + if (content_length > 0) { return true; } @@ -628,10 +628,9 @@ Http3Transaction::has_request_body(int64_t content_length, bool is_chunked_set) } // No body if stream is already closed and DATA frame is not received yet - // TODO stream state - // if () { - // return false; - // } + if (this->_info.adapter.stream().has_no_more_data()) { + return false; + } // No body if trailing header is received and DATA frame is not received yet // TODO trailing header
