Commit Graph

251 Commits

Author SHA1 Message Date
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
Marten Seemann
3d89e545d3 use the new crypto/tls QUIC Transport (#3860) 2023-07-01 11:15:00 -07:00
Marten Seemann
21388c86bb drop support for draft-29 (#3903) 2023-06-21 04:06:44 -07:00
Jean-Francois Giorgi
9acce3c6d9 http3: return http.ErrServerClosed instead of quic.ErrServerClosed (#3900)
* - fix 3898

* fix gofumpt

* - refactoring: inline  serveListener in ServeListener
- use ServeListener in s.serveConn
- updated doc for the returned error

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-06-20 09:32:56 -07:00
Glonee
9237dbb167 http3: close the connection when closing the roundtripper (#3873) 2023-06-01 01:06:13 -07:00
Glonee
c96fbd2e4a http3: correctly use the quic.Transport (#3869)
* use quic.Transport in http3

* add intergrationtests to dial server with different server names

* update test
2023-05-31 23:31:20 -07:00
Glonee
21549fcb4a http3: set tls.Config.ServerName for outgoing requests, if unset (#3867)
* fix #3865

* add test case

* Update http3/client, client_test.go

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

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-05-31 22:45:56 -07:00
Glonee
cec79d338c implement http3.RoundTripper.CloseIdleConnections (#3820)
* implement CloseIdleConnections

* nit

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

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-05-15 00:12:00 -07:00
Marten Seemann
7a0ef5f867 make Config.Allow0RTT a bool, not a callback 2023-05-02 15:56:49 +02:00
Marten Seemann
86a1234c87 make EarlyListener a struct, not an interface 2023-05-01 14:41:16 +02:00
Marten Seemann
aee7706d5d clean up dial functions
* add a context to all Dial functions
* remove the explicit Dial{*}Context functions
2023-05-01 13:59:54 +02:00
Marten Seemann
d683b841c4 remove the host parameter from all dial functions 2023-05-01 13:59:54 +02:00
Marten Seemann
2b0a03a988 set the QUIC version for integration tests using a command line flag 2023-05-01 13:43:34 +02:00
Kévin Dunglas
172123c340 http3: add compatibility with net/http.ResponseController (#3790)
* feat: compatibility with "net/http".ResponseController

* better deadline tests

* don't run deadline tests on Go 1.19

* skip deadline tests on Go 1.19
2023-05-01 04:40:33 -07:00
Marten Seemann
c9a2f79b1c simplify mockgen usage for private interfaces (#3769) 2023-04-19 07:57:00 -07:00
Marten Seemann
1f57d4e789 protocol: remove VersionTLS, used during the gQUIC -> TLS 1.3 transition (#3764) 2023-04-19 07:24:34 -07:00
Jean-Francois Giorgi
3f06880917 http3: check scheme before host to be consistent with net/http (#3774)
* check scheme before host so the error is comprehensible  and consistent with net/http

* Update http3/roundtrip.go

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

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2023-04-17 02:34:51 -07:00
Jean-Francois Giorgi
af517bdef1 http3: make error codes public and consistent with http2 package (#3744)
* make http3 error codes public and consistent with http2 package

* typo on ErrNoError

* renaming of ErrCode values
2023-04-07 21:53:14 -07:00