From 424bf2c3a79ecec0a1482acb12f037c6055ec252 Mon Sep 17 00:00:00 2001 From: Jan Habermann Date: Sun, 5 Feb 2023 08:53:24 +0100 Subject: [PATCH 1/2] Fix typo for optional_data (closes #1567) --- capi/libuwebsockets.cpp | 30 +++++++++++++++--------------- capi/libuwebsockets.h | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/capi/libuwebsockets.cpp b/capi/libuwebsockets.cpp index bfe143f5c..e2bb12fa0 100644 --- a/capi/libuwebsockets.cpp +++ b/capi/libuwebsockets.cpp @@ -1154,51 +1154,51 @@ extern "C" return uwsRes->hasResponded(); } - void uws_res_on_writable(int ssl, uws_res_t *res, bool (*handler)(uws_res_t *res, uintmax_t, void *opcional_data), void *opcional_data) + void uws_res_on_writable(int ssl, uws_res_t *res, bool (*handler)(uws_res_t *res, uintmax_t, void *optional_data), void *optional_data) { if (ssl) { uWS::HttpResponse *uwsRes = (uWS::HttpResponse *)res; - uwsRes->onWritable([handler, res, opcional_data](uintmax_t a) - { return handler(res, a, opcional_data); }); + uwsRes->onWritable([handler, res, optional_data](uintmax_t a) + { return handler(res, a, optional_data); }); } else { uWS::HttpResponse *uwsRes = (uWS::HttpResponse *)res; - uwsRes->onWritable([handler, res, opcional_data](uintmax_t a) - { return handler(res, a, opcional_data); }); + uwsRes->onWritable([handler, res, optional_data](uintmax_t a) + { return handler(res, a, optional_data); }); } } - void uws_res_on_aborted(int ssl, uws_res_t *res, void (*handler)(uws_res_t *res, void *opcional_data), void *opcional_data) + void uws_res_on_aborted(int ssl, uws_res_t *res, void (*handler)(uws_res_t *res, void *optional_data), void *optional_data) { if (ssl) { uWS::HttpResponse *uwsRes = (uWS::HttpResponse *)res; - uwsRes->onAborted([handler, res, opcional_data] - { handler(res, opcional_data); }); + uwsRes->onAborted([handler, res, optional_data] + { handler(res, optional_data); }); } else { uWS::HttpResponse *uwsRes = (uWS::HttpResponse *)res; - uwsRes->onAborted([handler, res, opcional_data] - { handler(res, opcional_data); }); + uwsRes->onAborted([handler, res, optional_data] + { handler(res, optional_data); }); } } - void uws_res_on_data(int ssl, uws_res_t *res, void (*handler)(uws_res_t *res, const char *chunk, size_t chunk_length, bool is_end, void *opcional_data), void *opcional_data) + void uws_res_on_data(int ssl, uws_res_t *res, void (*handler)(uws_res_t *res, const char *chunk, size_t chunk_length, bool is_end, void *optional_data), void *optional_data) { if (ssl) { uWS::HttpResponse *uwsRes = (uWS::HttpResponse *)res; - uwsRes->onData([handler, res, opcional_data](auto chunk, bool is_end) - { handler(res, chunk.data(), chunk.length(), is_end, opcional_data); }); + uwsRes->onData([handler, res, optional_data](auto chunk, bool is_end) + { handler(res, chunk.data(), chunk.length(), is_end, optional_data); }); } else { uWS::HttpResponse *uwsRes = (uWS::HttpResponse *)res; - uwsRes->onData([handler, res, opcional_data](auto chunk, bool is_end) - { handler(res, chunk.data(), chunk.length(), is_end, opcional_data); }); + uwsRes->onData([handler, res, optional_data](auto chunk, bool is_end) + { handler(res, chunk.data(), chunk.length(), is_end, optional_data); }); } } diff --git a/capi/libuwebsockets.h b/capi/libuwebsockets.h index 77c73f814..33182f2f1 100644 --- a/capi/libuwebsockets.h +++ b/capi/libuwebsockets.h @@ -222,9 +222,9 @@ extern "C" DLL_EXPORT uintmax_t uws_res_get_write_offset(int ssl, uws_res_t *res); DLL_EXPORT void uws_res_override_write_offset(int ssl, uws_res_t *res, uintmax_t offset); DLL_EXPORT bool uws_res_has_responded(int ssl, uws_res_t *res); - DLL_EXPORT void uws_res_on_writable(int ssl, uws_res_t *res, bool (*handler)(uws_res_t *res, uintmax_t, void *opcional_data), void *user_data); - DLL_EXPORT void uws_res_on_aborted(int ssl, uws_res_t *res, void (*handler)(uws_res_t *res, void *opcional_data), void *opcional_data); - DLL_EXPORT void uws_res_on_data(int ssl, uws_res_t *res, void (*handler)(uws_res_t *res, const char *chunk, size_t chunk_length, bool is_end, void *opcional_data), void *opcional_data); + DLL_EXPORT void uws_res_on_writable(int ssl, uws_res_t *res, bool (*handler)(uws_res_t *res, uintmax_t, void *optional_data), void *user_data); + DLL_EXPORT void uws_res_on_aborted(int ssl, uws_res_t *res, void (*handler)(uws_res_t *res, void *optional_data), void *optional_data); + DLL_EXPORT void uws_res_on_data(int ssl, uws_res_t *res, void (*handler)(uws_res_t *res, const char *chunk, size_t chunk_length, bool is_end, void *optional_data), void *optional_data); DLL_EXPORT void uws_res_upgrade(int ssl, uws_res_t *res, void *data, const char *sec_web_socket_key, size_t sec_web_socket_key_length, const char *sec_web_socket_protocol, size_t sec_web_socket_protocol_length, const char *sec_web_socket_extensions, size_t sec_web_socket_extensions_length, uws_socket_context_t *ws); DLL_EXPORT size_t uws_res_get_remote_address(int ssl, uws_res_t *res, const char **dest); DLL_EXPORT size_t uws_res_get_remote_address_as_text(int ssl, uws_res_t *res, const char **dest); From 46a0a1c85c3997387d7cdcfed212f965d7d88ffd Mon Sep 17 00:00:00 2001 From: Jan Habermann Date: Sun, 5 Feb 2023 08:54:44 +0100 Subject: [PATCH 2/2] Fix typo in comment --- src/HttpResponse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HttpResponse.h b/src/HttpResponse.h index 180725b2e..bf4d38132 100644 --- a/src/HttpResponse.h +++ b/src/HttpResponse.h @@ -230,7 +230,7 @@ struct HttpResponse : public AsyncSocket { #endif /* Manually upgrade to WebSocket. Typically called in upgrade handler. Immediately calls open handler. - * NOTE: Will invalidate 'this' as socket might change location in memory. Throw away aftert use. */ + * NOTE: Will invalidate 'this' as socket might change location in memory. Throw away after use. */ template void upgrade(UserData &&userData, std::string_view secWebSocketKey, std::string_view secWebSocketProtocol, std::string_view secWebSocketExtensions,