]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /* |
2 | * Copyright (c) 2017 Uber Technologies, Inc. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | #ifndef JAEGERTRACING_NET_HTTP_RESPONSE_H | |
18 | #define JAEGERTRACING_NET_HTTP_RESPONSE_H | |
19 | ||
20 | #include "jaegertracing/net/URI.h" | |
21 | #include "jaegertracing/net/Socket.h" | |
22 | #include "jaegertracing/net/http/Error.h" | |
23 | #include "jaegertracing/net/http/Header.h" | |
24 | #include "jaegertracing/net/http/Method.h" | |
25 | ||
26 | namespace jaegertracing { | |
27 | namespace net { | |
28 | namespace http { | |
29 | ||
30 | class Response { | |
31 | public: | |
32 | static Response parse(std::istream& in); | |
33 | ||
34 | Response() | |
35 | : _version() | |
36 | , _statusCode(0) | |
37 | , _reason() | |
38 | , _headers() | |
39 | , _body() | |
40 | { | |
41 | } | |
42 | ||
43 | int statusCode() const { return _statusCode; } | |
44 | ||
45 | const std::string& reason() const { return _reason; } | |
46 | ||
47 | const std::vector<Header>& headers() const { return _headers; } | |
48 | ||
49 | const std::string& body() const { return _body; } | |
50 | ||
51 | private: | |
52 | std::string _version; | |
53 | int _statusCode; | |
54 | std::string _reason; | |
55 | std::vector<Header> _headers; | |
56 | std::string _body; | |
57 | }; | |
58 | ||
59 | Response get(const URI& uri); | |
60 | ||
61 | /** | |
62 | * Reads http response from a socket | |
63 | */ | |
64 | Response read(Socket& socket); | |
65 | ||
66 | } // namespace http | |
67 | } // namespace net | |
68 | } // namespace jaegertracing | |
69 | ||
70 | #endif // JAEGERTRACING_NET_HTTP_RESPONSE_H |