/root/doris/be/src/http/http_method.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <event2/http.h> |
21 | | |
22 | | #include <string> |
23 | | |
24 | | namespace doris { |
25 | | |
26 | | // Http method enumerate |
27 | | enum HttpMethod { GET, PUT, POST, DELETE, HEAD, OPTIONS, UNKNOWN }; |
28 | | |
29 | | // Convert string to HttpMethod |
30 | | HttpMethod to_http_method(const char* method); |
31 | | |
32 | 20 | inline HttpMethod to_http_method(evhttp_cmd_type type) { |
33 | 20 | switch (type) { |
34 | 6 | case EVHTTP_REQ_GET: |
35 | 6 | return HttpMethod::GET; |
36 | 10 | case EVHTTP_REQ_POST: |
37 | 10 | return HttpMethod::POST; |
38 | 4 | case EVHTTP_REQ_HEAD: |
39 | 4 | return HttpMethod::HEAD; |
40 | 0 | case EVHTTP_REQ_PUT: |
41 | 0 | return HttpMethod::PUT; |
42 | 0 | case EVHTTP_REQ_DELETE: |
43 | 0 | return HttpMethod::DELETE; |
44 | 0 | case EVHTTP_REQ_OPTIONS: |
45 | 0 | return HttpMethod::OPTIONS; |
46 | 0 | default: |
47 | 0 | return HttpMethod::UNKNOWN; |
48 | 20 | } |
49 | 0 | return HttpMethod::UNKNOWN; |
50 | 20 | } |
51 | | |
52 | | std::string to_method_desc(const HttpMethod& method); |
53 | | |
54 | | } // namespace doris |