Skip to content

Commit

Permalink
added uws_req_get_case_sensitive_method in C API (uNetworking#1506)
Browse files Browse the repository at this point in the history
* added uwsReq.getCaseSensitiveMethod()

* uws_req_get_case_sensitive_method header

* add license

* update license
  • Loading branch information
cirospaciari authored Nov 1, 2022
1 parent 2a2c3ec commit bba6c9b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
30 changes: 30 additions & 0 deletions capi/libuwebsockets.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions capi/libuwebsockets.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bba6c9b

Please sign in to comment.