aboutsummaryrefslogtreecommitdiff
path: root/src/deps
diff options
context:
space:
mode:
Diffstat (limited to 'src/deps')
-rw-r--r--src/deps/_libusockets.h8
-rw-r--r--src/deps/libuwsockets.cpp20
-rw-r--r--src/deps/uws.zig27
3 files changed, 46 insertions, 9 deletions
diff --git a/src/deps/_libusockets.h b/src/deps/_libusockets.h
index 7042d3d14..8c65d36ab 100644
--- a/src/deps/_libusockets.h
+++ b/src/deps/_libusockets.h
@@ -5,8 +5,8 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
-#include <uws/uSockets/src/libusockets.h>
-
+#include <uws/src/App.h>
+#include <uws/src/AsyncSocket.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -225,7 +225,7 @@ void uws_res_end(int ssl, uws_res_t *res, const char *data, size_t length,
bool close_connection);
void uws_res_pause(int ssl, uws_res_t *res);
void uws_res_resume(int ssl, uws_res_t *res);
-void uws_res_write_continue(int ssl, uws_res_t *res);
+void uws_res_write_continwue(int ssl, uws_res_t *res);
void uws_res_write_status(int ssl, uws_res_t *res, const char *status,
size_t length);
void uws_res_write_header(int ssl, uws_res_t *res, const char *key,
@@ -291,6 +291,8 @@ void uws_res_write_headers(int ssl, uws_res_t *res, const StringPointer *names,
const StringPointer *values, size_t count,
const char *buf);
+void *uws_res_get_native_handle(int ssl, uws_res_t *res);
+void uws_res_uncork(int ssl, uws_res_t *res);
#ifdef __cplusplus
}
#endif
diff --git a/src/deps/libuwsockets.cpp b/src/deps/libuwsockets.cpp
index 132a22be8..628d30df5 100644
--- a/src/deps/libuwsockets.cpp
+++ b/src/deps/libuwsockets.cpp
@@ -1001,6 +1001,16 @@ void uws_res_write_headers(int ssl, uws_res_t *res, const StringPointer *names,
}
}
+void uws_res_uncork(int ssl, uws_res_t *res) {
+ // if (ssl) {
+ // uWS::HttpResponse<true> *uwsRes = (uWS::HttpResponse<true> *)res;
+ // uwsRes->uncork();
+ // } else {
+ // uWS::HttpResponse<false> *uwsRes = (uWS::HttpResponse<false> *)res;
+ // uwsRes->uncork();
+ // }
+}
+
void uws_res_cork(int ssl, uws_res_t *res, void *ctx,
void (*corker)(void *ctx)) {
if (ssl) {
@@ -1011,4 +1021,14 @@ void uws_res_cork(int ssl, uws_res_t *res, void *ctx,
uwsRes->cork([ctx, corker]() { corker(ctx); });
}
}
+
+void *uws_res_get_native_handle(int ssl, uws_res_t *res) {
+ if (ssl) {
+ uWS::HttpResponse<true> *uwsRes = (uWS::HttpResponse<true> *)res;
+ return uwsRes->getNativeHandle();
+ } else {
+ uWS::HttpResponse<false> *uwsRes = (uWS::HttpResponse<false> *)res;
+ return uwsRes->getNativeHandle();
+ }
+}
} \ No newline at end of file
diff --git a/src/deps/uws.zig b/src/deps/uws.zig
index 30e23b39a..c72fefd71 100644
--- a/src/deps/uws.zig
+++ b/src/deps/uws.zig
@@ -410,6 +410,12 @@ pub fn NewApp(comptime ssl: bool) type {
pub fn end(res: *Response, data: []const u8, close_connection: bool) void {
uws_res_end(ssl_flag, res.downcast(), data.ptr, data.len, close_connection);
}
+ pub fn uncork(_: *Response) void {
+ // uws_res_uncork(
+ // ssl_flag,
+ // res.downcast(),
+ // );
+ }
pub fn pause(res: *Response) void {
uws_res_pause(ssl_flag, res.downcast());
}
@@ -426,7 +432,7 @@ pub fn NewApp(comptime ssl: bool) type {
uws_res_write_header(ssl_flag, res.downcast(), key.ptr, key.len, value.ptr, value.len);
}
pub fn writeHeaderInt(res: *Response, key: []const u8, value: u64) void {
- uws_res_write_header(ssl_flag, res.downcast(), key.ptr, key.len, value);
+ uws_res_write_header_int(ssl_flag, res.downcast(), key.ptr, key.len, value);
}
pub fn endWithoutBody(res: *Response) void {
uws_res_end_without_body(ssl_flag, res.downcast());
@@ -440,18 +446,26 @@ pub fn NewApp(comptime ssl: bool) type {
pub fn hasResponded(res: *Response) bool {
return uws_res_has_responded(ssl_flag, res.downcast());
}
+
+ pub fn getNativeHandle(res: *Response) i32 {
+ return @intCast(i32, @ptrToInt(uws_res_get_native_handle(ssl_flag, res.downcast())));
+ }
pub fn onWritable(
res: *Response,
comptime UserDataType: type,
- comptime handler: fn (*Response, uintmax_t, UserDataType) callconv(.C) bool,
+ comptime handler: fn (UserDataType, uintmax_t, *Response) callconv(.C) bool,
user_data: UserDataType,
) void {
const Wrapper = struct {
- pub fn handle(this: *uws_res, amount: uintmax_t, data: ?*anyopaque) callconv(.C) void {
+ pub fn handle(this: *uws_res, amount: uintmax_t, data: ?*anyopaque) callconv(.C) bool {
if (comptime UserDataType == void) {
- @call(.{ .modifier = .always_inline }, handler, .{ void{}, castRes(this), amount });
+ return @call(.{ .modifier = .always_inline }, handler, .{ void{}, amount, castRes(this) });
} else {
- @call(.{ .modifier = .always_inline }, handler, .{ @ptrCast(UserDataType, @alignCast(@alignOf(UserDataType), data.?)), castRes(this), amount });
+ return @call(.{ .modifier = .always_inline }, handler, .{
+ @ptrCast(UserDataType, @alignCast(@alignOf(UserDataType), data.?)),
+ amount,
+ castRes(this),
+ });
}
}
};
@@ -533,7 +547,7 @@ pub fn NewApp(comptime ssl: bool) type {
};
};
}
-
+extern fn uws_res_get_native_handle(ssl: c_int, res: *uws_res) *us_socket_t;
extern fn uws_create_app(ssl: c_int, options: us_socket_context_options_t) *uws_app_t;
extern fn uws_app_destroy(ssl: c_int, app: *uws_app_t) void;
extern fn uws_app_get(ssl: c_int, app: *uws_app_t, pattern: [*c]const u8, handler: uws_method_handler, user_data: ?*anyopaque) void;
@@ -580,6 +594,7 @@ extern fn uws_ws_get_buffered_amount(ssl: c_int, ws: ?*uws_websocket_t) c_uint;
extern fn uws_ws_get_remote_address(ssl: c_int, ws: ?*uws_websocket_t, dest: [*c][*c]const u8) usize;
extern fn uws_ws_get_remote_address_as_text(ssl: c_int, ws: ?*uws_websocket_t, dest: [*c][*c]const u8) usize;
const uws_res = opaque {};
+extern fn uws_res_uncork(ssl: c_int, res: *uws_res) void;
extern fn uws_res_end(ssl: c_int, res: *uws_res, data: [*c]const u8, length: usize, close_connection: bool) void;
extern fn uws_res_pause(ssl: c_int, res: *uws_res) void;
extern fn uws_res_resume(ssl: c_int, res: *uws_res) void;