added uws_req_get_case_sensitive_method in C API (#1506)

* added uwsReq.getCaseSensitiveMethod()

* uws_req_get_case_sensitive_method header

* add license

* update license
This commit is contained in:
Ciro Spaciari
2022-11-01 22:24:08 +01:00
committed by GitHub
parent 2a2c3ecb45
commit bba6c9b0cd
2 changed files with 53 additions and 0 deletions
+30
View File
@@ -1,3 +1,25 @@
/*
* Copyright 2022 Ciro Spaciari
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "libuwebsockets.h"
#include <string_view>
#include "App.h"
@@ -1145,6 +1167,14 @@ extern "C"
return value.length();
}
size_t uws_req_get_case_sensitive_method(uws_req_t *res, const char **dest)
{
uWS::HttpRequest *uwsReq = (uWS::HttpRequest *)res;
std::string_view value = uwsReq->getCaseSensitiveMethod();
*dest = value.data();
return value.length();
}
void uws_req_for_each_header(uws_req_t *res, uws_get_headers_server_handler handler, void *user_data)
{
uWS::HttpRequest *uwsReq = (uWS::HttpRequest *)res;
+23
View File
@@ -1,3 +1,24 @@
/*
* Copyright 2022 Ciro Spaciari
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef LIBUWS_CAPI_HEADER
#define LIBUWS_CAPI_HEADER
@@ -208,6 +229,8 @@ extern "C"
size_t uws_req_get_url(uws_req_t *res, const char **dest);
size_t uws_req_get_full_url(uws_req_t *res, const char **dest);
size_t uws_req_get_method(uws_req_t *res, const char **dest);
size_t uws_req_get_case_sensitive_method(uws_req_t *res, const char **dest);
size_t uws_req_get_header(uws_req_t *res, const char *lower_case_header, size_t lower_case_header_length, const char **dest);
void uws_req_for_each_header(uws_req_t *res, uws_get_headers_server_handler handler, void *user_data);
size_t uws_req_get_query(uws_req_t *res, const char *key, size_t key_length, const char **dest);