summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/HttpResponse.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/HttpResponse.h
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/utils/HttpResponse.h')
-rw-r--r--xbmc/utils/HttpResponse.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/xbmc/utils/HttpResponse.h b/xbmc/utils/HttpResponse.h
new file mode 100644
index 0000000..50fc739
--- /dev/null
+++ b/xbmc/utils/HttpResponse.h
@@ -0,0 +1,125 @@
1/*
2 * Copyright (C) 2011-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include <map>
12#include <string>
13#include <utility>
14#include <vector>
15
16namespace HTTP
17{
18 enum Version
19 {
20 Version1_0,
21 Version1_1
22 };
23
24 enum Method
25 {
26 Get,
27 Head,
28 POST,
29 PUT,
30 Delete,
31 Trace,
32 Connect
33 };
34
35 enum StatusCode
36 {
37 // Information 1xx
38 Continue = 100,
39 SwitchingProtocols = 101,
40 Processing = 102,
41 ConnectionTimedOut = 103,
42
43 // Success 2xx
44 OK = 200,
45 Created = 201,
46 Accepted = 202,
47 NonAuthoritativeInformation = 203,
48 NoContent = 204,
49 ResetContent = 205,
50 PartialContent = 206,
51 MultiStatus = 207,
52
53 // Redirects 3xx
54 MultipleChoices = 300,
55 MovedPermanently = 301,
56 Found = 302,
57 SeeOther = 303,
58 NotModified = 304,
59 UseProxy = 305,
60 //SwitchProxy = 306,
61 TemporaryRedirect = 307,
62
63 // Client errors 4xx
64 BadRequest = 400,
65 Unauthorized = 401,
66 PaymentRequired = 402,
67 Forbidden = 403,
68 NotFound = 404,
69 MethodNotAllowed = 405,
70 NotAcceptable = 406,
71 ProxyAuthenticationRequired = 407,
72 RequestTimeout = 408,
73 Conflict = 409,
74 Gone = 410,
75 LengthRequired = 411,
76 PreconditionFailed = 412,
77 RequestEntityTooLarge = 413,
78 RequestURITooLong = 414,
79 UnsupportedMediaType = 415,
80 RequestedRangeNotSatisfiable = 416,
81 ExpectationFailed = 417,
82 ImATeapot = 418,
83 TooManyConnections = 421,
84 UnprocessableEntity = 422,
85 Locked = 423,
86 FailedDependency = 424,
87 UnorderedCollection = 425,
88 UpgradeRequired = 426,
89
90 // Server errors 5xx
91 InternalServerError = 500,
92 NotImplemented = 501,
93 BadGateway = 502,
94 ServiceUnavailable = 503,
95 GatewayTimeout = 504,
96 HTTPVersionNotSupported = 505,
97 VariantAlsoNegotiates = 506,
98 InsufficientStorage = 507,
99 BandwidthLimitExceeded = 509,
100 NotExtended = 510
101 };
102}
103
104class CHttpResponse
105{
106public:
107 CHttpResponse(HTTP::Method method, HTTP::StatusCode status, HTTP::Version version = HTTP::Version1_1);
108
109 void AddHeader(const std::string &field, const std::string &value);
110 void SetContent(const char* data, unsigned int length);
111
112 std::string Create();
113
114private:
115 HTTP::Method m_method;
116 HTTP::StatusCode m_status;
117 HTTP::Version m_version;
118 std::vector< std::pair<std::string, std::string> > m_headers;
119 const char* m_content;
120 unsigned int m_contentLength;
121 std::string m_buffer;
122
123 static std::map<HTTP::StatusCode, std::string> m_statusCodeText;
124 static std::map<HTTP::StatusCode, std::string> createStatusCodes();
125};