1
1
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
2
2
3
3
#include " application.h"
4
- #include < debug_utils-inl.h>
5
4
#include < async_wrap-inl.h>
5
+ #include < debug_utils-inl.h>
6
6
#include < node_bob.h>
7
7
#include < node_sockaddr-inl.h>
8
8
#include < uv.h>
9
9
#include < v8.h>
10
10
#include " defs.h"
11
11
#include " endpoint.h"
12
+ #include " http3.h"
12
13
#include " packet.h"
13
14
#include " session.h"
14
15
@@ -23,33 +24,20 @@ using v8::Value;
23
24
24
25
namespace quic {
25
26
26
- struct Session ::Application::StreamData final {
27
- // The actual number of vectors in the struct, up to kMaxVectorCount.
28
- size_t count = 0 ;
29
- size_t remaining = 0 ;
30
- // The stream identifier. If this is a negative value then no stream is
31
- // identified.
32
- int64_t id = -1 ;
33
- int fin = 0 ;
34
- ngtcp2_vec data[kMaxVectorCount ]{};
35
- ngtcp2_vec* buf = data;
36
- BaseObjectPtr<Stream> stream;
37
- };
38
-
39
27
// ============================================================================
40
28
// Session::Application_Options
41
29
const Session::Application_Options Session::Application_Options::kDefault = {};
42
30
43
31
Session::Application_Options::operator const nghttp3_settings () const {
44
32
// In theory, Application_Options might contain options for more than just
45
33
// HTTP/3. Here we extract only the properties that are relevant to HTTP/3.
46
- return nghttp3_settings {
47
- max_field_section_size,
48
- qpack_max_dtable_capacity,
49
- qpack_encoder_max_dtable_capacity,
50
- qpack_blocked_streams,
51
- enable_connect_protocol,
52
- enable_datagrams,
34
+ return nghttp3_settings{
35
+ max_field_section_size,
36
+ qpack_max_dtable_capacity,
37
+ qpack_encoder_max_dtable_capacity,
38
+ qpack_blocked_streams,
39
+ enable_connect_protocol,
40
+ enable_datagrams,
53
41
};
54
42
}
55
43
@@ -59,13 +47,14 @@ std::string Session::Application_Options::ToString() const {
59
47
std::string res (" {" );
60
48
res += prefix + " max header pairs: " + std::to_string (max_header_pairs);
61
49
res += prefix + " max header length: " + std::to_string (max_header_length);
62
- res += prefix + " max field section size: " +
63
- std::to_string (max_field_section_size);
50
+ res += prefix +
51
+ " max field section size: " + std::to_string (max_field_section_size);
64
52
res += prefix + " qpack max dtable capacity: " +
65
53
std::to_string (qpack_max_dtable_capacity);
66
54
res += prefix + " qpack encoder max dtable capacity: " +
67
55
std::to_string (qpack_encoder_max_dtable_capacity);
68
- res += prefix + " qpack blocked streams: " + std::to_string (qpack_blocked_streams);
56
+ res += prefix +
57
+ " qpack blocked streams: " + std::to_string (qpack_blocked_streams);
69
58
res += prefix + " enable connect protocol: " +
70
59
(enable_connect_protocol ? std::string (" yes" ) : std::string (" no" ));
71
60
res += prefix + " enable datagrams: " +
@@ -118,7 +107,10 @@ bool Session::Application::Start() {
118
107
119
108
void Session::Application::AcknowledgeStreamData (Stream* stream,
120
109
size_t datalen) {
121
- Debug (session_, " Application acknowledging stream %" PRIi64 " data: %zu" , stream->id (), datalen);
110
+ Debug (session_,
111
+ " Application acknowledging stream %" PRIi64 " data: %zu" ,
112
+ stream->id (),
113
+ datalen);
122
114
DCHECK_NOT_NULL (stream);
123
115
stream->Acknowledge (datalen);
124
116
}
@@ -184,7 +176,8 @@ Session::Application::ExtractSessionTicketAppData(
184
176
void Session::Application::SetStreamPriority (const Stream& stream,
185
177
StreamPriority priority,
186
178
StreamPriorityFlags flags) {
187
- Debug (session_, " Application setting stream %" PRIi64 " priority" , stream.id ());
179
+ Debug (
180
+ session_, " Application setting stream %" PRIi64 " priority" , stream.id ());
188
181
// By default do nothing.
189
182
}
190
183
@@ -201,20 +194,29 @@ BaseObjectPtr<Packet> Session::Application::CreateStreamDataPacket() {
201
194
}
202
195
203
196
void Session::Application::StreamClose (Stream* stream, QuicError error) {
204
- Debug (session_, " Application closing stream %" PRIi64 " with error %s" , stream->id (), error);
197
+ Debug (session_,
198
+ " Application closing stream %" PRIi64 " with error %s" ,
199
+ stream->id (),
200
+ error);
205
201
stream->Destroy (error);
206
202
}
207
203
208
204
void Session::Application::StreamStopSending (Stream* stream, QuicError error) {
209
- Debug (session_, " Application stopping sending on stream %" PRIi64 " with error %s" , stream->id (), error);
205
+ Debug (session_,
206
+ " Application stopping sending on stream %" PRIi64 " with error %s" ,
207
+ stream->id (),
208
+ error);
210
209
DCHECK_NOT_NULL (stream);
211
210
stream->ReceiveStopSending (error);
212
211
}
213
212
214
213
void Session::Application::StreamReset (Stream* stream,
215
214
uint64_t final_size,
216
215
QuicError error) {
217
- Debug (session_, " Application resetting stream %" PRIi64 " with error %s" , stream->id (), error);
216
+ Debug (session_,
217
+ " Application resetting stream %" PRIi64 " with error %s" ,
218
+ stream->id (),
219
+ error);
218
220
stream->ReceiveStreamReset (final_size, error);
219
221
}
220
222
@@ -498,13 +500,14 @@ class DefaultApplication final : public Session::Application {
498
500
};
499
501
500
502
std::unique_ptr<Session::Application> Session::select_application () {
501
- // if (config.options.crypto_options.alpn == NGHTTP3_ALPN_H3)
502
- // return std::make_unique<Http3>(session,
503
- // config.options.application_options);
504
-
505
503
// In the future, we may end up supporting additional QUIC protocols. As they
506
504
// are added, extend the cases here to create and return them.
507
505
506
+ if (config_.options .tls_options .alpn == NGHTTP3_ALPN_H3) {
507
+ Debug (this , " Selecting HTTP/3 application" );
508
+ return createHttp3Application (this , config_.options .application_options );
509
+ }
510
+
508
511
Debug (this , " Selecting default application" );
509
512
return std::make_unique<DefaultApplication>(
510
513
this , config_.options .application_options );
0 commit comments