1
0
mirror of https://github.com/lammertb/libhttp.git synced 2026-01-27 08:02:47 +03:00

Moved is valid_http_method to own file

This commit is contained in:
Lammert Bies
2016-12-11 00:10:10 +01:00
parent 7aed402edd
commit 8d2b1fdfaf
3 changed files with 65 additions and 29 deletions

View File

@@ -73,6 +73,7 @@ LIB_SOURCES = src/libhttp.c \
src/httplib_handle_websocket_request.c \
src/httplib_initialize_ssl.c \
src/httplib_is_not_modified.c \
src/httplib_is_valid_http_method.c \
src/httplib_is_websocket_protocol.c \
src/httplib_load_dll.c \
src/httplib_lock_unlock_connection.c \

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2016 Lammert Bies
* Copyright (c) 2013-2016 the Civetweb developers
* Copyright (c) 2004-2013 Sergey Lyubka
*
* 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 "libhttp-private.h"
/*
* int XX_httplib_is_valid_http_method( const char *method );
*
* The function XX_httplib_is_valid_http_method() checks if the method in a
* request is a valid method.
*/
int XX_httplib_is_valid_http_method( const char *method ) {
return !strcmp(method, "GET") /* HTTP (RFC 2616) */
|| !strcmp(method, "POST") /* HTTP (RFC 2616) */
|| !strcmp(method, "HEAD") /* HTTP (RFC 2616) */
|| !strcmp(method, "PUT") /* HTTP (RFC 2616) */
|| !strcmp(method, "DELETE") /* HTTP (RFC 2616) */
|| !strcmp(method, "OPTIONS") /* HTTP (RFC 2616) */
/* TRACE method (RFC 2616) is not supported for security reasons */
|| !strcmp(method, "CONNECT") /* HTTP (RFC 2616) */
|| !strcmp(method, "PROPFIND") /* WEBDAV (RFC 2518) */
|| !strcmp(method, "MKCOL") /* WEBDAV (RFC 2518) */
/* Unsupported WEBDAV Methods: */
/* PROPPATCH, COPY, MOVE, LOCK, UNLOCK (RFC 2518) */
/* + 11 methods from RFC 3253 */
/* ORDERPATCH (RFC 3648) */
/* ACL (RFC 3744) */
/* SEARCH (RFC 5323) */
/* + MicroSoft extensions
* https://msdn.microsoft.com/en-us/library/aa142917.aspx */
/* PATCH method only allowed for CGI/Lua/LSP and callbacks. */
|| !strcmp(method, "PATCH"); /* PATCH method (RFC 5789) */
} /* XX_httplib_is_valid_http_method */

View File

@@ -5250,32 +5250,3 @@ int XX_httplib_parse_http_headers( char **buf, struct mg_request_info *ri ) {
return ri->num_headers;
} /* XX_httplib_parse_http_headers */
int XX_httplib_is_valid_http_method( const char *method ) {
return !strcmp(method, "GET") /* HTTP (RFC 2616) */
|| !strcmp(method, "POST") /* HTTP (RFC 2616) */
|| !strcmp(method, "HEAD") /* HTTP (RFC 2616) */
|| !strcmp(method, "PUT") /* HTTP (RFC 2616) */
|| !strcmp(method, "DELETE") /* HTTP (RFC 2616) */
|| !strcmp(method, "OPTIONS") /* HTTP (RFC 2616) */
/* TRACE method (RFC 2616) is not supported for security reasons */
|| !strcmp(method, "CONNECT") /* HTTP (RFC 2616) */
|| !strcmp(method, "PROPFIND") /* WEBDAV (RFC 2518) */
|| !strcmp(method, "MKCOL") /* WEBDAV (RFC 2518) */
/* Unsupported WEBDAV Methods: */
/* PROPPATCH, COPY, MOVE, LOCK, UNLOCK (RFC 2518) */
/* + 11 methods from RFC 3253 */
/* ORDERPATCH (RFC 3648) */
/* ACL (RFC 3744) */
/* SEARCH (RFC 5323) */
/* + MicroSoft extensions
* https://msdn.microsoft.com/en-us/library/aa142917.aspx */
/* PATCH method only allowed for CGI/Lua/LSP and callbacks. */
|| !strcmp(method, "PATCH"); /* PATCH method (RFC 5789) */
} /* XX_httplib_is_valid_http_method */