be/src/service/http/http_response.h
Line | Count | Source |
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 <map> |
21 | | #include <string> |
22 | | #include <vector> |
23 | | |
24 | | #include "service/http/http_status.h" |
25 | | |
26 | | namespace doris { |
27 | | |
28 | | class HttpResponse { |
29 | | public: |
30 | | // Only have to send status line |
31 | | HttpResponse(const HttpStatus& status); |
32 | | |
33 | | // status and content |
34 | | HttpResponse(const HttpStatus& status, const std::string* content); |
35 | | |
36 | | // status and content |
37 | | HttpResponse(const HttpStatus& status, const std::string& type, const std::string* content); |
38 | | |
39 | | // Add one header |
40 | | void add_header(const std::string& key, const std::string& value); |
41 | | |
42 | 0 | const std::map<std::string, std::vector<std::string>>& headers() const { |
43 | 0 | return _custom_headers; |
44 | 0 | } |
45 | | |
46 | 0 | const std::string* content() const { return _content; } |
47 | | |
48 | 0 | const std::string& content_type() const { return _content_type; } |
49 | | |
50 | 0 | HttpStatus status() const { return _status; } |
51 | | |
52 | | private: |
53 | | HttpStatus _status; |
54 | | std::string _content_type; |
55 | | const std::string* _content; |
56 | | std::map<std::string, std::vector<std::string>> _custom_headers; |
57 | | }; |
58 | | |
59 | | } // namespace doris |