More listen overloads

This commit is contained in:
Alex Hultman
2022-05-15 18:58:31 +02:00
parent 73c9262f34
commit c2f29c86c7
2 changed files with 31 additions and 2 deletions
+30 -1
View File
@@ -25,8 +25,37 @@ namespace uWS {
other.http3Context = nullptr;
}
H3App &&listen(int port, std::function<void(void *)> cb) {
/* Host, port, callback */
H3App &&listen(std::string host, int port, MoveOnlyFunction<void(us_listen_socket_t *)> &&handler) {
if (!host.length()) {
return listen(port, std::move(handler));
}
http3Context->listen();
//handler(httpContext ? httpContext->listen(host.c_str(), port, 0) : nullptr);
return std::move(*this);
}
/* Host, port, options, callback */
H3App &&listen(std::string host, int port, int options, MoveOnlyFunction<void(us_listen_socket_t *)> &&handler) {
if (!host.length()) {
return listen(port, options, std::move(handler));
}
http3Context->listen();
//handler(httpContext ? httpContext->listen(host.c_str(), port, options) : nullptr);
return std::move(*this);
}
/* Port, callback */
H3App &&listen(int port, MoveOnlyFunction<void(us_listen_socket_t *)> &&handler) {
http3Context->listen();
//handler(httpContext ? httpContext->listen(nullptr, port, 0) : nullptr);
return std::move(*this);
}
/* Port, options, callback */
H3App &&listen(int port, int options, MoveOnlyFunction<void(us_listen_socket_t *)> &&handler) {
http3Context->listen();
//handler(http3Context ? http3Context->listen(nullptr, port, options) : nullptr);
return std::move(*this);
}
+1 -1
View File
@@ -12,7 +12,7 @@ namespace uWS {
int name_length, value_length;
if (more = us_quic_socket_context_get_header(nullptr, i, &name, &name_length, &value, &value_length)) {
if (name_length == key.length() && !memcmp(name, key.data(), key.length())) {
return {value, value_length};
return {value, (size_t) value_length};
}
}
}