Skip to content

Commit c2f29c8

Browse files
committed
More listen overloads
1 parent 73c9262 commit c2f29c8

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/Http3App.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,37 @@ namespace uWS {
2525
other.http3Context = nullptr;
2626
}
2727

28-
H3App &&listen(int port, std::function<void(void *)> cb) {
28+
/* Host, port, callback */
29+
H3App &&listen(std::string host, int port, MoveOnlyFunction<void(us_listen_socket_t *)> &&handler) {
30+
if (!host.length()) {
31+
return listen(port, std::move(handler));
32+
}
33+
http3Context->listen();
34+
//handler(httpContext ? httpContext->listen(host.c_str(), port, 0) : nullptr);
35+
return std::move(*this);
36+
}
37+
38+
/* Host, port, options, callback */
39+
H3App &&listen(std::string host, int port, int options, MoveOnlyFunction<void(us_listen_socket_t *)> &&handler) {
40+
if (!host.length()) {
41+
return listen(port, options, std::move(handler));
42+
}
43+
http3Context->listen();
44+
//handler(httpContext ? httpContext->listen(host.c_str(), port, options) : nullptr);
45+
return std::move(*this);
46+
}
47+
48+
/* Port, callback */
49+
H3App &&listen(int port, MoveOnlyFunction<void(us_listen_socket_t *)> &&handler) {
50+
http3Context->listen();
51+
//handler(httpContext ? httpContext->listen(nullptr, port, 0) : nullptr);
52+
return std::move(*this);
53+
}
54+
55+
/* Port, options, callback */
56+
H3App &&listen(int port, int options, MoveOnlyFunction<void(us_listen_socket_t *)> &&handler) {
2957
http3Context->listen();
58+
//handler(http3Context ? http3Context->listen(nullptr, port, options) : nullptr);
3059
return std::move(*this);
3160
}
3261

src/Http3Request.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace uWS {
1212
int name_length, value_length;
1313
if (more = us_quic_socket_context_get_header(nullptr, i, &name, &name_length, &value, &value_length)) {
1414
if (name_length == key.length() && !memcmp(name, key.data(), key.length())) {
15-
return {value, value_length};
15+
return {value, (size_t) value_length};
1616
}
1717
}
1818
}

0 commit comments

Comments
 (0)