Merge pull request #26220 from 78andyp/blurayfixes
[xbmc.git] / xbmc / utils / HttpResponse.h
blob50fc73958ca96b2aacd30f208e39f252804a45f2
1 /*
2 * Copyright (C) 2011-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include <map>
12 #include <string>
13 #include <utility>
14 #include <vector>
16 namespace HTTP
18 enum Version
20 Version1_0,
21 Version1_1
24 enum Method
26 Get,
27 Head,
28 POST,
29 PUT,
30 Delete,
31 Trace,
32 Connect
35 enum StatusCode
37 // Information 1xx
38 Continue = 100,
39 SwitchingProtocols = 101,
40 Processing = 102,
41 ConnectionTimedOut = 103,
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,
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,
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,
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
104 class CHttpResponse
106 public:
107 CHttpResponse(HTTP::Method method, HTTP::StatusCode status, HTTP::Version version = HTTP::Version1_1);
109 void AddHeader(const std::string &field, const std::string &value);
110 void SetContent(const char* data, unsigned int length);
112 std::string Create();
114 private:
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;
123 static std::map<HTTP::StatusCode, std::string> m_statusCodeText;
124 static std::map<HTTP::StatusCode, std::string> createStatusCodes();