Commit Graph

56 Commits

Author SHA1 Message Date
Roman Arutyunyan eea23ac250 HTTP/3: "quic" parameter of "listen" directive.
Now "listen" directve has a new "quic" parameter which enables QUIC protocol
for the address.  Further, to enable HTTP/3, a new directive "http3" is
introduced.  The hq-interop protocol is enabled by "http3_hq" as before.
Now application protocol is chosen by ALPN.

Previously used "http3" parameter of "listen" is deprecated.
2023-02-27 14:00:56 +04:00
Roman Arutyunyan aa58c6457a QUIC: application init() callback.
It's called after handshake completion or prior to the first early data stream
creation.  The callback should initialize application-level data before
creating streams.

HTTP/3 callback implementation sets keepalive timer and sends SETTINGS.

Also, this allows to limit max handshake time in ngx_http_v3_init_stream().
2022-11-30 12:51:15 +04:00
Roman Arutyunyan 2fb971a6b9 HTTP/3: renamed functions.
ngx_http_v3_init() is renamed ngx_http_v3_init_stream().
ngx_http_v3_reset_connection() is renamed to ngx_http_v3_reset_stream().
2022-08-22 14:09:03 +04:00
Roman Arutyunyan 595a642018 QUIC: idle mode for main connection.
Now main QUIC connection for HTTP/3 always has c->idle flag set.  This allows
the connection to receive worker shutdown notification.  It is passed to
application level via a new conf->shutdown() callback.

The HTTP/3 shutdown callback sends GOAWAY to client and gracefully shuts down
the QUIC connection.
2022-10-19 17:45:18 +04:00
Roman Arutyunyan 7cccd64670 HTTP/3: unified hq code with regular HTTP/3 code.
The change removes hq-specific request handler.  Now hq requests are handled
by the HTTP/3 request handler.
2022-10-19 17:45:30 +04:00
Sergey Kandaurov 658e350aae HTTP/3: updated SETTINGS_MAX_FIELD_SECTION_SIZE name. 2022-06-08 16:19:01 +04:00
Roman Arutyunyan d503544196 QUIC: allowed main QUIC connection for some operations.
Operations like ngx_quic_open_stream(), ngx_http_quic_get_connection(),
ngx_http_v3_finalize_connection(), ngx_http_v3_shutdown_connection() used to
receive a QUIC stream connection.  Now they can receive the main QUIC
connection as well.  This is useful when calling them from a stream context.
2022-01-31 09:16:47 +03:00
Sergey Kandaurov 6c4bd8acd6 HTTP/3: removed draft versions support in ALPN. 2022-01-26 14:15:40 +03:00
Sergey Kandaurov d98314233f HTTP/3: improved processing of multiple Cookie field lines.
As per draft-ietf-quic-http, 4.1.1.2, and similar to HTTP/2 specification,
they ought to be concatenated.  This closely follows ngx_http_v2_module.
2021-12-30 12:59:32 +03:00
Roman Arutyunyan bd8e49cbc6 HTTP/3: renamed files.
ngx_http_v3_tables.h and ngx_http_v3_tables.c are renamed to
ngx_http_v3_table.h and ngx_http_v3_table.c to better match HTTP/2 code.

ngx_http_v3_streams.h and ngx_http_v3_streams.c are renamed to
ngx_http_v3_uni.h and ngx_http_v3_uni.c to better match their content.
2021-12-07 13:01:28 +03:00
Vladimir Homutov c1d88961cb QUIC: simplified configuration.
Directives that set transport parameters are removed from the configuration.
Corresponding values are derived from the quic configuration or initialized
to default.  Whenever possible, quic configuration parameters are taken from
higher-level protocol settings, i.e. HTTP/3.
2021-12-06 15:19:54 +03:00
Roman Arutyunyan 88d2f21fc9 HTTP/3: http3_hq directive and NGX_HTTP_V3_HQ macro.
Listen quic parameter is no longer supported.
2021-12-04 10:52:55 +03:00
Roman Arutyunyan 6dc747f5ff HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module. 2021-12-06 13:02:36 +03:00
Sergey Kandaurov 1cf5df0781 HTTP/3: adjusted ALPN macro names to align with 61abb35bb8cf. 2021-12-02 13:59:09 +03:00
Roman Arutyunyan f72a2bb3f6 HTTP/3: allowed QUIC stream connection reuse.
A QUIC stream connection is treated as reusable until first bytes of request
arrive, which is also when the request object is now allocated.  A connection
closed as a result of draining, is reset with the error code
H3_REQUEST_REJECTED.  Such behavior is allowed by quic-http-34:

   Once a request stream has been opened, the request MAY be cancelled
   by either endpoint. Clients cancel requests if the response is no
   longer of interest; servers cancel requests if they are unable to or
   choose not to respond.

   When the server cancels a request without performing any application
   processing, the request is considered "rejected."  The server SHOULD
   abort its response stream with the error code H3_REQUEST_REJECTED.

   The client can treat requests rejected by the server as though they had
   never been sent at all, thereby allowing them to be retried later.
2021-10-18 15:47:06 +03:00
Roman Arutyunyan 6fe2069e12 HTTP/3: traffic-based flood detection.
With this patch, all traffic over HTTP/3 bidi and uni streams is counted in
the h3c->total_bytes field, and payload traffic is counted in the
h3c->payload_bytes field.  As long as total traffic is many times larger than
payload traffic, we consider this to be a flood.

Request header traffic is counted as if all fields are literal.  Response
header traffic is counted as is.
2021-10-07 13:22:42 +03:00
Roman Arutyunyan ecadcc5186 HTTP/3: replaced macros with values. 2021-08-04 17:35:11 +03:00
Roman Arutyunyan a63a5cfdc0 HTTP/3: http3_max_uni_streams directive.
The directive limits the number of uni streams client is allowed to create.
2021-07-29 12:17:56 +03:00
Roman Arutyunyan a3b881bf6c HTTP/3: client GOAWAY support. 2021-06-11 13:24:24 +03:00
Roman Arutyunyan 2afd4c612e HTTP/3: separate header files for existing source files. 2021-05-05 15:09:23 +03:00
Roman Arutyunyan a830f1da3b HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Previously it was parsed in ngx_http_v3_streams.c, while the streams were
parsed in ngx_http_v3_parse.c.  Now all parsing is done in one file.  This
simplifies parsing API and cleans up ngx_http_v3_streams.c.
2021-05-05 15:00:17 +03:00
Roman Arutyunyan 65121fd06d HTTP/3: renamed ngx_http_v3_client_XXX() functions.
The functions are renamed to ngx_http_v3_send_XXX() similar to
ngx_http_v3_send_settings() and ngx_http_v3_send_goaway().
2021-04-27 21:32:50 +03:00
Roman Arutyunyan 193e598f14 HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t. 2021-05-05 12:54:10 +03:00
Roman Arutyunyan 968daa6a69 HTTP/3: reference h3c directly from ngx_http_connection_t.
Previously, an ngx_http_v3_connection_t object was created for HTTP/3 and
then assinged to c->data instead of the generic ngx_http_connection_t object.
Now a direct reference is added to ngx_http_connection_t, which is less
confusing and does not require a flag for http3.
2021-05-05 14:53:36 +03:00
Roman Arutyunyan 041da3d5a7 HTTP/3: ngx_http_v3_get_session() macro.
It's used instead of accessing c->quic->parent->data directly.  Apart from being
simpler, it allows to change the way session is stored in the future by changing
the macro.
2021-04-30 19:10:11 +03:00
Sergey Kandaurov 73b9640ea3 HTTP/3: keepalive_time support. 2021-04-16 19:42:03 +03:00
Sergey Kandaurov ecbde796e8 HTTP/3: removed h3scf->quic leftover after 0d2b2664b41c. 2021-04-12 12:30:30 +03:00
Roman Arutyunyan 529409c0a0 HTTP/3: keepalive timeout.
This timeout limits the time when no client request streams exist.
2021-03-30 16:48:38 +03:00
Roman Arutyunyan 6b36b11167 QUIC: connection shutdown.
The function ngx_quic_shutdown_connection() waits until all non-cancelable
streams are closed, and then closes the connection.  In HTTP/3 cancelable
streams are all unidirectional streams except push streams.

The function is called from HTTP/3 when client reaches keepalive_requests.
2021-03-15 16:39:33 +03:00
Roman Arutyunyan 67c58e696f HTTP/3: send GOAWAY when last request is accepted.
The last request in connection is determined according to the keepalive_requests
directive.  Requests beyond keepalive_requests are rejected.
2021-03-15 19:26:04 +03:00
Roman Arutyunyan f9f6ded228 HTTP/3: limited client header size.
The limit is the size of all large client header buffers.  Client header size
is the total size of all client header names and values.
2021-02-17 11:58:32 +03:00
Roman Arutyunyan e33795e354 HTTP/3: introduced ngx_http_v3_parse_t structure.
The structure is used to parse an HTTP/3 request.  An object of this type is
added to ngx_http_request_t instead of h3_parse generic pointer.

Also, the new field is located outside of the request ephemeral zone to keep it
safe after request headers are parsed.
2021-02-17 15:56:34 +03:00
Roman Arutyunyan 189d24c21b HTTP/3: removed http3_max_field_size.
Instead, size of one large_client_header_buffers buffer is used.
2021-02-16 18:50:01 +03:00
Roman Arutyunyan b56ed96a16 HTTP/3: refactored request body parser.
The change reduces diff to the default branch for
src/http/ngx_http_request_body.c.

Also, client Content-Length, if present, is now checked against the real body
size sent by client.
2021-01-25 16:16:47 +03:00
Roman Arutyunyan 979b89029f HTTP/3: added comment. 2021-01-12 21:08:55 +00:00
Roman Arutyunyan 50430c7e1d HTTP/3: refactored request parser.
The change reduces diff to the default branch for
src/http/ngx_http_request.c and src/http/ngx_http_parse.c.
2021-01-22 16:34:06 +03:00
Roman Arutyunyan dc5ab4196f HTTP/3: introduced ngx_http_v3_filter.
The filter is responsible for creating HTTP/3 response header and body.

The change removes differences to the default branch for
ngx_http_chunked_filter_module and ngx_http_header_filter_module.
2020-11-27 17:46:21 +00:00
Roman Arutyunyan e7985ce0ab QUIC: renamed c->qs to c->quic. 2020-11-10 19:40:00 +00:00
Sergey Kandaurov cb43caba9d QUIC: multiple versions support in ALPN.
Previously, a version based on NGX_QUIC_DRAFT_VERSION was always set.
Now it is taken from the negotiated QUIC version that may differ.
2020-11-10 00:32:56 +03:00
Roman Arutyunyan 1cb69c22fa HTTP/3: server pushes.
New directives are added:
- http3_max_concurrent_pushes
- http3_push
- http3_push_preload
2020-07-23 13:41:24 +03:00
Roman Arutyunyan 459fd8e589 HTTP/3: header encoding functions. 2020-07-13 16:00:00 +03:00
Roman Arutyunyan 0c9a1fd9cc QUIC: added "quic" listen parameter.
The parameter allows processing HTTP/0.9-2 over QUIC.

Also, introduced ngx_http_quic_module and moved QUIC settings there
2020-07-21 23:09:22 +03:00
Roman Arutyunyan df0a95b586 HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Previously errors led only to closing streams.

To simplify closing QUIC connection from a QUIC stream context, new macro
ngx_http_v3_finalize_connection() is introduced.  It calls
ngx_quic_finalize_connection() for the parent connection.
2020-07-02 16:47:51 +03:00
Roman Arutyunyan a3fd09e793 HTTP/3: error code definitions for HTTP/3 and QPACK. 2020-06-30 12:30:57 +03:00
Roman Arutyunyan 8a99b8cabd HTTP/3: refactored dynamic table implementation.
Previously dynamic table was not functional because of zero limit on its size
set by default.  Now the following changes enable it:

- new directives to set SETTINGS_QPACK_MAX_TABLE_CAPACITY and
  SETTINGS_QPACK_BLOCKED_STREAMS
- send settings with SETTINGS_QPACK_MAX_TABLE_CAPACITY and
  SETTINGS_QPACK_BLOCKED_STREAMS to the client
- send Insert Count Increment to the client
- send Header Acknowledgement to the client
- evict old dynamic table entries on overflow
- decode Required Insert Count from client
- block stream if Required Insert Count is not reached
2020-07-02 15:34:05 +03:00
Roman Arutyunyan 9e72031709 HTTP/3: http3_max_field_size directive to limit string size.
Client streams may send literal strings which are now limited in size by the
new directive.  The default value is 4096.

The directive is similar to HTTP/2 directive http2_max_field_size.
2020-06-29 15:56:14 +03:00
Roman Arutyunyan 9eae53813f HTTP/3: introduced ngx_http_v3_get_module_srv_conf() macro.
The macro helps to access a module's server configuration from a QUIC
stream context.
2020-06-26 11:58:00 +03:00
Roman Arutyunyan e6c8d371a7 HTTP/3: restricted symbols in header names.
As per HTTP/3 draft 27, a request or response containing uppercase header
field names MUST be treated as malformed.  Also, existing rules applied
when parsing HTTP/1 header names are also applied to HTTP/3 header names:

- null character is not allowed
- underscore character may or may not be treated as invalid depending on the
  value of "underscores_in_headers"
- all non-alphanumeric characters with the exception of '-' are treated as
  invalid

Also, the r->locase_header field is now filled while parsing an HTTP/3
header.

Error logging for invalid headers is fixed as well.
2020-05-19 15:34:00 +03:00
Roman Arutyunyan 28bcacbe7a HTTP/3: split header parser in two functions.
The first one parses pseudo-headers and is analagous to the request line
parser in HTTP/1.  The second one parses regular headers and is analogous to
the header parser in HTTP/1.

Additionally, error handling of client passing malformed uri is now fixed.
2020-05-19 15:29:10 +03:00
Roman Arutyunyan 48a1eeb5c2 Parsing HTTP/3 request body. 2020-03-27 19:41:06 +03:00