2 * Copyright (C) 2016, 2017 "IoT.bzh"
3 * Author: José Bollo <jose.bollo@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #include <microhttpd.h>
21 #include "afb-method.h"
23 enum afb_method get_method(const char *method)
25 switch (method[0] & ~' ') {
27 return afb_method_connect;
29 return afb_method_delete;
31 return afb_method_get;
33 return afb_method_head;
35 return afb_method_options;
37 switch (method[1] & ~' ') {
39 return afb_method_patch;
41 return afb_method_post;
43 return afb_method_put;
47 return afb_method_trace;
49 return afb_method_none;
52 #if !defined(MHD_HTTP_METHOD_PATCH)
53 #define MHD_HTTP_METHOD_PATCH "PATCH"
55 const char *get_method_name(enum afb_method method)
59 return MHD_HTTP_METHOD_GET;
61 return MHD_HTTP_METHOD_POST;
63 return MHD_HTTP_METHOD_HEAD;
64 case afb_method_connect:
65 return MHD_HTTP_METHOD_CONNECT;
66 case afb_method_delete:
67 return MHD_HTTP_METHOD_DELETE;
68 case afb_method_options:
69 return MHD_HTTP_METHOD_OPTIONS;
70 case afb_method_patch:
71 return MHD_HTTP_METHOD_PATCH;
73 return MHD_HTTP_METHOD_PUT;
74 case afb_method_trace:
75 return MHD_HTTP_METHOD_TRACE;