Commit Graph

418 Commits

Author SHA1 Message Date
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
Glonee
36f7fe7d07 http3: discard body from responses to HEAD requests (#4115)
* http3: HEAD method should not have a body

* add tests

* Update http3/server.go

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

* ruduce the size of responseWriter

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-10-22 19:31:24 -07:00
Marten Seemann
a263164d9f use new gomock feature to generate type-safe methods in mocks (#4057) 2023-10-20 22:55:33 -07:00
Marten Seemann
9a397abc17 update gomock to v0.3.0 (#4087) 2023-09-24 04:38:28 -07:00
Marten Seemann
d8cc4cb3ef http3: introduce an HTTP/3 error type (#4039)
* http3: introduce an HTTP/3 error type

* http3: use a pointer receiver for the Error
2023-09-16 04:57:50 -07:00
Marten Seemann
2797f85fc0 switch from unmaintained golang/mock to go.uber.org/mock (#4050) 2023-08-28 02:23:55 -07:00
WeidiDeng
824fd8a2f2 http3: automatically add content-length for small responses (#3989)
* response writer: add content-length automatically when response is small enough and doesn't call Flush

* fix comment

* add integration test

* Update http3/response_writer.go

* Update integrationtests/self/http_test.go

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-08-20 20:31:22 -07:00
Marten Seemann
70f3f44a09 http3: remove leftover ALPN constant for draft-29 (#4027) 2023-08-13 19:36:01 -07:00
Ondrej Kokes
05db808f72 http3: change code point for HTTP datagrams to RFC 9297 (#3588)
* HTTP/3 Datagrams are now RFC 9297

* Use datatracker htmlized docs rather than rfc-editor (to be consistent)
2023-08-09 06:30:46 -07:00
roc
32f8b20ae5 http3: fix check for content length of the response (#3998)
* fix: check response content-length other than request content-length

* Update http3/client.go

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-07-28 21:18:26 -07:00
WeidiDeng
2c0e7e02b0 http3: panic in ResponseWriter.WriteHeader for invalid status codes (#3984)
* response writer: panic for invalid status code

* add tests

* readd imports

* readd imports

* fix imports
2023-07-21 09:50:51 -07:00
WeidiDeng
2183283622 http3: discard negative content-length header when writing response (#3983)
* response writer: discard negative content-length header

* shorten comment

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-07-20 11:42:37 -07:00
Marten Seemann
5a22ac8970 http3: enforce that DATA frames don't exceed Content-Length (#3980) 2023-07-20 09:47:01 -07:00
Marten Seemann
ae8bdd79e0 http3: use correct error code when request header parsing fails (#3979) 2023-07-19 11:46:10 -07:00
Marten Seemann
5ae28928db http3: reject unknown pseudo headers (#3973) 2023-07-18 22:42:26 -07:00
Marten Seemann
b6dbfc8c06 http3: reject responses that don't set the :status header (#3975) 2023-07-18 22:26:46 -07:00
Marten Seemann
5d59c3059f http3: deduplicate Content-Length headers (#3972) 2023-07-18 21:52:21 -07:00
Marten Seemann
bb296b8c17 http3: unify handling of request and response headers (#3969) 2023-07-18 21:39:05 -07:00
Marten Seemann
ad16aa765d http3: refactor header field processing into a separate function (#3971) 2023-07-18 21:16:50 -07:00
Marten Seemann
514df55288 http3: enforce ordering requirement between pseudo and regular headers (#3968)
* http3: enforce ordering requirement between pseudo and regular headers

* simplify logic
2023-07-18 09:13:16 -07:00
Marten Seemann
ab192a084d http3: reject negative values for the Content-Length header (#3966) 2023-07-17 19:23:54 -07:00
Marten Seemann
c4b3d979bd http3: reject header field values with invalid characters (#3967) 2023-07-17 18:56:29 -07:00
Marten Seemann
baee8184fc http3: reject header field names with invalid characters (#3965) 2023-07-17 18:33:24 -07:00
Marten Seemann
3edacebff0 http3: reject header field that contain non-lowercase characters (#3964) 2023-07-17 18:16:01 -07:00
Marten Seemann
8ac22a9483 http3: set the Content-Length header in the http.Request.Header map (#3963) 2023-07-16 19:26:15 -07:00
Marten Seemann
3dea8f8a9b http3: don't send more than http.Request.ContentLength bytes (#3960) 2023-07-16 19:16:52 -07:00
WeidiDeng
de8d7a32b8 http3: return http.ErrContentLength when writing too large response (#3953) 2023-07-12 23:20:35 -07:00
WeidiDeng
9e7fa4773a http3: implement FlushError for the response writer (#3951)
* implement FlushError interface for http3 response writer

* move where to log flush error
2023-07-12 20:40:53 -07:00
WeidiDeng
2c4371b6a9 http3: add Date response header if not set (#3952)
* automatically add date header if not already set

* improve comment for Date header

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-07-12 10:30:33 -07:00
WeidiDeng
f97c9bf88c http3: don't write response headers if the handler panicked (#3950) 2023-07-12 09:32:33 -07:00
Marten Seemann
fcf8d4b3ff http3: validate Host header before sending (#3948) 2023-07-11 23:27:24 -07:00