From ae2a956d88417f4a9d45a72dc0cd80ee76b6a871 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Tue, 10 Feb 2015 08:33:30 +0000 Subject: [PATCH] Feature: Added support for HTTP Methods: OPTIONS, DELETE, TRACE, CONNECT This added support for the standard HTTP/1.1 methods: * OPTIONS - Query the server to tell what features are supported. * DELETE - Delete a resource on a server. In Icecast2 context this is about what is known as 'kick source'. * TRACE - Asks the server to return the request to the client as body. The client is to send a body-less request and the server will return with a 200 OK and the body to to be the exact bitstream it got from the client (or any (reverse) proxy). The Content-Type is to be set to 'message/http'. * CONNECT - Client asks the server to proxy the request to the given resource. This hardly seems to make sense for Icecast2 but may be used by some clients such as libshout. Therefor I added it as well so we have at least an ID assigned to it. Please note that this is a ABI breaker and you will need to recompile your projects (use 'make clean all'). See: RFC2616 --- httpp/httpp.c | 20 ++++++++++++++++++++ httpp/httpp.h | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/httpp/httpp.c b/httpp/httpp.c index e42bff6..5e23a3a 100644 --- a/httpp/httpp.c +++ b/httpp/httpp.c @@ -398,6 +398,18 @@ int httpp_parse(http_parser_t *parser, const char *http_data, unsigned long len) case httpp_req_head: httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "HEAD"); break; + case httpp_req_options: + httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "OPTIONS"); + break; + case httpp_req_delete: + httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "DELETE"); + break; + case httpp_req_trace: + httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "TRACE"); + break; + case httpp_req_connect: + httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "CONNECT"); + break; case httpp_req_source: httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "SOURCE"); break; @@ -577,6 +589,14 @@ httpp_request_type_e httpp_str_to_method(const char * method) { return httpp_req_put; } else if (strcasecmp("HEAD", method) == 0) { return httpp_req_head; + } else if (strcasecmp("OPTIONS", method) == 0) { + return httpp_req_options; + } else if (strcasecmp("DELETE", method) == 0) { + return httpp_req_delete; + } else if (strcasecmp("TRACE", method) == 0) { + return httpp_req_trace; + } else if (strcasecmp("CONNECT", method) == 0) { + return httpp_req_connect; } else if (strcasecmp("SOURCE", method) == 0) { return httpp_req_source; } else if (strcasecmp("PLAY", method) == 0) { diff --git a/httpp/httpp.h b/httpp/httpp.h index 580fff4..226eb99 100644 --- a/httpp/httpp.h +++ b/httpp/httpp.h @@ -47,6 +47,10 @@ typedef enum httpp_request_type_tag { httpp_req_post, httpp_req_put, httpp_req_head, + httpp_req_options, + httpp_req_delete, + httpp_req_trace, + httpp_req_connect, /* Icecast SOURCE, to be replaced with PUT some day */ httpp_req_source, /* XXX: ??? */