Commit Graph

298 Commits

Author SHA1 Message Date
Marten Seemann
2a37c53143 http3: add support for HTTP Datagrams (RFC 9297) (#4452)
* http3: add support for HTTP Datagrams (RFC 9297)

* README: reference HTTP Datagrams (RFC 9297)
2024-04-26 11:21:04 -07:00
Marten Seemann
11b11594b2 http3: fix race condition in client unit test (#4463) 2024-04-26 10:32:03 -07:00
Marten Seemann
6a4512a6f0 http3: fix race condition when closing the RoundTripper (#4458) 2024-04-23 13:23:48 -07:00
mchtech
86b53a2516 http3: process 1xx status codes (#4437)
* process http 1xx status code

Signed-off-by: mchtech <michu_an@126.com>

* add integration tests

Signed-off-by: mchtech <michu_an@126.com>

* fix tests

---------

Signed-off-by: mchtech <michu_an@126.com>
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2024-04-21 02:56:45 -07:00
Marten Seemann
3e7ba77a77 http3: check server SETTINGS before sending an Extended CONNECT request (#4450) 2024-04-20 06:21:36 -07:00
Marten Seemann
18422ad1c4 http3: remove RoundTripOpt.CheckSettings (#4416)
The settings can be obtained from the SingleDestinationRoundTripper.
2024-04-20 02:42:33 -07:00
Marten Seemann
9bc7bd84cc http3: use a log/slog.Logger for logging (#4449) 2024-04-20 01:59:58 -07:00
George
248189d252 http3: don't remove clients on RoundTripOpt context canceled (#4448)
* fix(http3): reuse clients on RoundTripOpt context cancelled

Signed-off-by: George MacRorie <me@georgemac.com>

* chore(http3): add comment to context canceled check on roundtrip error

---------

Signed-off-by: George MacRorie <me@georgemac.com>
2024-04-20 01:47:34 -07:00
Marten Seemann
e48e1d465d http3: simplify response header writing (#4441) 2024-04-17 09:44:36 -07:00
Marten Seemann
788b6f4409 http3: fix flaky RoundTripper test (#4442) 2024-04-17 09:44:20 -07:00
Marten Seemann
457ac2c4dc http3: move length limiting logic to the body (#4439)
The length limit is a property of the (request and response) body. As
such, it's better implemented there than by wrapping the HTTP stream.
2024-04-17 01:26:45 -07:00
Marten Seemann
29785b29bf http3: simplify tracking of content length (#4438) 2024-04-16 06:35:31 -07:00
Marten Seemann
afd0b061d5 http3: remove Accept(Uni)Stream methods from the Connection interface (#4435)
Incoming streams are hijacked, not accepted.
2024-04-14 08:37:01 -07:00
Marten Seemann
25cd4b5d24 http3: simplify composition of the HTTP stream and request stream (#4433) 2024-04-13 17:18:51 -07:00
Marten Seemann
90627f6f7c http3: simplify buffering of small responses (#4432) 2024-04-13 16:46:19 -07:00
Marten Seemann
b096e94092 http3: hide SendDatagram and ReceiveDatagram on the Connection (#4427)
HTTP datagrams are bound to streams. It shouldn't be possible to send
datagrams on the http3.Connection.
2024-04-11 14:13:34 -07:00
Marten Seemann
da410a7b59 http3: expose a SingleDestinationRoundTripper (#4424) 2024-04-11 09:55:05 -07:00
Marten Seemann
9efc324637 http3: remove Settingser, StreamCreator, return Connection from Hijacker (#4425) 2024-04-11 08:47:00 -07:00
Marten Seemann
ee698b326f http3: cancel reading on request stream if request processing fails (#4417) 2024-04-09 13:34:00 -07:00
Marten Seemann
eb310a6db8 http3: expose an OpenStream method on the RoundTripper (#4409)
The stream exposes two methods required for doing an HTTP request:
SendRequestHeader and ReadResponse. This can be used by applications
that wish to use the stream for non-HTTP content afterwards. This will
lead to a simplification in the API we need to expose for WebTransport,
and will make it easier to send HTTP Datagrams associated with this
stream.
2024-04-09 13:14:14 -07:00
Marten Seemann
183d42a729 http3: pass tracing ID instead of quic.Connection to stream hijackers (#4401)
The stream hijackers only need to be able to associate the stream with
the underlying QUIC connection. They are not supposed to call any
functions on the quic.Connection. As such, the better API is to just
pass them a unique identifier.
2024-04-01 21:23:40 -07:00
Marten Seemann
f389b638d2 http3: reference the correct RFCs in doc comments (#4399) 2024-04-01 15:56:23 -07:00
Marten Seemann
97d31dad39 http3: introduce a Settingser to query the client's SETTINGS (#4389)
The http.Request.Body can be type-asserted to a http3.Settingser. The
Settings method on this interface blocks until the client's SETTINGS
frame has been received.
2024-03-31 14:44:42 -07:00
Marten Seemann
d540f545b0 http3: reject duplicate QPACK decoder and encoder streams (#4388) 2024-03-24 14:17:11 -07:00
Marten Seemann
268208fbef http3: refactor the client's and server's unidirectional stream handling (#4387)
The logic is almost identical, so it makes sense to refactor it into
a shared implementation.
2024-03-24 13:52:44 -07:00
Marten Seemann
49b9965525 http3: rename RoundTripper.QuicConfig to RoundTripper.QUICConfig (#4385) 2024-03-23 15:29:39 -07:00
Marten Seemann
89020e380a http3: rename Server.QuicConfig to Server.QUICConfig (#4384) 2024-03-23 14:39:34 -07:00
Marten Seemann
7d902549b7 http3: fix capitalization of Server.SetQUICHeaders (#4377)
Server.SetQuicHeaders is deprecated now, and will be removed at some
point in the future.
2024-03-23 14:24:51 -07:00
Marten Seemann
684b80a23f http3: don't modify any fields of the http.Request when doing 0-RTT (#4379) 2024-03-23 13:58:41 -07:00
Marten Seemann
603e07779a http3: make it possible to send HEAD requests in 0-RTT (#4378) 2024-03-23 08:24:09 +10:00
Marten Seemann
e14dd2fe5b http3: improve documentation for Server.SetQuicHeaders (#4376) 2024-03-21 17:24:37 -07:00
Marten Seemann
6325696fde quicvarint: use int return value instead of internal protocol.ByteCount (#4356) 2024-03-19 14:56:55 -07:00
Marten Seemann
497d3f58a5 http3: add a RoundTripOpt to check the server's SETTINGS frame (#4355)
For some requests, the client is required to check the server's HTTP/3
SETTINGS. For example, a client is only allowed to send HTTP/3 datagrams
if the server explicitly enabled support.

SETTINGS are sent asynchronously on a control stream (usually the first
unidirectional stream). This means that the SETTINGS might not be
available at the beginning of the connection. This is not expected to be
the common case, since the server can send the SETTINGS in 0.5-RTT data,
but we have to be able to deal with arbitrary delays.

For WebTransport, there are even more SETTINGS values that the client
needs to check. By making CheckSettings a callback on the RoundTripOpt,
this entire validation logic can live at the WebTransport layer.
2024-03-12 01:03:00 -07:00
Marten Seemann
f1476390f2 update gomock to v0.4.0 (#4361) 2024-03-10 18:07:20 -07:00
Marten Seemann
d41c0b68cd http3: reject duplicate control streams opened by the client (#4344) 2024-03-02 23:52:52 -08:00
Marten Seemann
c5f7096f00 http3: reject duplicate control streams opened by the server (#4342) 2024-03-02 23:28:24 -08:00
Marten Seemann
9813766373 http3: send SETTINGS_ENABLE_CONNECT_PROTOCOL (for Extended CONNECT) (#4341) 2024-03-02 23:15:59 -08:00
Marten Seemann
0405634108 http3: don't automatically set RoundTripper.QuicConfig.EnableDatagrams (#4340)
If the user provides a quic.Config, we shouldn't modify it. Instead, we
should return an error if the user enables HTTP Datagrams but fails to
enable datagrams on the QUIC layer.
2024-03-02 22:39:21 -08:00
Marten Seemann
fbaa941ea1 protocol: rename VersionNumber to Version (#4295) 2024-01-31 21:57:33 -08:00
taoso
808f849ca2 http3: only use :protocol pseudo-header for Extended CONNECT (#4261)
* Fix protocol

The default value should be "HTTP/3.0".

* Reject normal request with :protocol header

The :protocol pseudo header is only defined for
Extended Connect requests (RFC 9220).

* save one branch check

* Fix review issue
2024-01-25 19:07:35 -08:00
Marten Seemann
d3c2020ecd http3: add a basic README (#4246) 2024-01-16 19:34:10 -08:00
Robin Thellend
3ff50295ce http3: add ConnContext to the server (#4230)
* Add ConnContext to http3.Server

ConnContext can be used to modify the context used by a new http
Request.

* Make linter happy

* Add nil check and integration test

* Add the ServerContextKey check to the ConnContext func

* Update integrationtests/self/http_test.go

Co-authored-by: Marten Seemann <martenseemann@gmail.com>

* Update http3/server.go

Co-authored-by: Marten Seemann <martenseemann@gmail.com>

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2024-01-04 19:13:53 -08:00
Vladimir Varankin
a937959fbf http3: fix channel size in ListenAndServe (#4219)
* http3: typo in ListenAndServe docs

Also, partially prevent a goroutine leak on an error from one of the
listeners.

* http3: improve documentation for ListenAndServe

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-12-28 18:35:46 -08:00
Marten Seemann
22411e16d5 utils: switch to standard library min and max functions (#4218)
These functions were added in Go 1.21.
2023-12-27 21:19:13 -08:00
Marten Seemann
2243fdefbf http3: return the context cancellation error from RoundTrip (#4203) 2023-12-20 20:16:30 -08:00
Constantine Shablia
d3c5f389d4 http3: improve debug message when determining the listener port fails (#4214)
Fixes: #4212
2023-12-18 21:03:28 -08:00
Constantine Shablia
5d6bf7e206 http3: don't use error string as a format string in debug log message (#4211)
Fixes: #4209
2023-12-18 19:27:07 -08:00
WeidiDeng
e0bf13be01 http3: reset stream when a handler panics (#4181)
* interrupt the stream when a panick happened

* move the declaration of errPanicked

* check what's read is a prefix of what's written

* check errPanicked

* use MatchError instead of Equal

* use channel to notify the response has been received
2023-12-15 19:39:49 -08:00
Dominik Roos
06c6a8449b http3: add remote address to request context (#4208)
* http3: add remote address to request context

Add the remote address of the underlying packet connection to the
HTTP request context. This is useful for applications that need access
to the actual remote address (wrapped in a net.Addr) rather than just
its string representation.

Fixes #4198

* add an integration test to the self test suite.

I was not sure how deep we want to go to assure the right value is set.
For now, it asserts that a net.Addr is present in the context.

Due to the dynamic nature of the requests, it is a bit harder to know
exactly how the remote address will look like. IPv4 vs IPv6, random high
port. I think it is fine to only assert that the value is present.
2023-12-15 19:29:41 -08:00
Marten Seemann
9b40c50a73 http3: use the AdditionalSettings for requests (#4156) 2023-12-06 06:22:23 -08:00