summaryrefslogtreecommitdiff
path: root/indra/llmessage/llhttpconstants.h
blob: d6bcbd3c19329ed1a2aa1bd4bcfdd1ed4bbde317 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/** 
 * @file llhttpconstants.h
 * @brief Constants for HTTP requests and responses
 *
 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2001-2014, Linden Research, Inc.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License only.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 * $/LicenseInfo$
 */

#ifndef LL_HTTP_CONSTANTS_H
#define LL_HTTP_CONSTANTS_H

#include "stdtypes.h"

/////// HTTP STATUS CODES ///////

// Standard errors from HTTP spec:
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1
const S32 HTTP_CONTINUE = 100;
const S32 HTTP_SWITCHING_PROTOCOLS = 101;

// Success
const S32 HTTP_OK = 200;
const S32 HTTP_CREATED = 201;
const S32 HTTP_ACCEPTED = 202;
const S32 HTTP_NON_AUTHORITATIVE_INFORMATION = 203;
const S32 HTTP_NO_CONTENT = 204;
const S32 HTTP_RESET_CONTENT = 205;
const S32 HTTP_PARTIAL_CONTENT = 206;

// Redirection
const S32 HTTP_MULTIPLE_CHOICES = 300;
const S32 HTTP_MOVED_PERMANENTLY = 301;
const S32 HTTP_FOUND = 302;
const S32 HTTP_SEE_OTHER = 303;
const S32 HTTP_NOT_MODIFIED = 304;
const S32 HTTP_USE_PROXY = 305;
const S32 HTTP_TEMPORARY_REDIRECT = 307;

// Client Error
const S32 HTTP_BAD_REQUEST = 400;
const S32 HTTP_UNAUTHORIZED = 401;
const S32 HTTP_PAYMENT_REQUIRED = 402;
const S32 HTTP_FORBIDDEN = 403;
const S32 HTTP_NOT_FOUND = 404;
const S32 HTTP_METHOD_NOT_ALLOWED = 405;
const S32 HTTP_NOT_ACCEPTABLE = 406;
const S32 HTTP_PROXY_AUTHENTICATION_REQUIRED = 407;
const S32 HTTP_REQUEST_TIME_OUT = 408;
const S32 HTTP_CONFLICT = 409;
const S32 HTTP_GONE = 410;
const S32 HTTP_LENGTH_REQUIRED = 411;
const S32 HTTP_PRECONDITION_FAILED = 412;
const S32 HTTP_REQUEST_ENTITY_TOO_LARGE = 413;
const S32 HTTP_REQUEST_URI_TOO_LARGE = 414;
const S32 HTTP_UNSUPPORTED_MEDIA_TYPE = 415;
const S32 HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
const S32 HTTP_EXPECTATION_FAILED = 417;

// Server Error
const S32 HTTP_INTERNAL_SERVER_ERROR = 500;
const S32 HTTP_NOT_IMPLEMENTED = 501;
const S32 HTTP_BAD_GATEWAY = 502;
const S32 HTTP_SERVICE_UNAVAILABLE = 503;
const S32 HTTP_GATEWAY_TIME_OUT = 504;
const S32 HTTP_VERSION_NOT_SUPPORTED = 505;

// We combine internal process errors with status codes
// These status codes should not be sent over the wire
//   and indicate something went wrong internally.
// If you get these they are not normal.
const S32 HTTP_INTERNAL_CURL_ERROR = 498;
const S32 HTTP_INTERNAL_ERROR = 499;


////// HTTP Methods //////

extern const std::string HTTP_VERB_INVALID;
extern const std::string HTTP_VERB_HEAD;
extern const std::string HTTP_VERB_GET;
extern const std::string HTTP_VERB_PUT;
extern const std::string HTTP_VERB_POST;
extern const std::string HTTP_VERB_DELETE;
extern const std::string HTTP_VERB_MOVE;
extern const std::string HTTP_VERB_OPTIONS;

enum EHTTPMethod
{
	HTTP_INVALID = 0,
	HTTP_HEAD,
	HTTP_GET,
	HTTP_PUT,
	HTTP_POST,
	HTTP_DELETE,
	HTTP_MOVE, // Caller will need to set 'Destination' header
	HTTP_OPTIONS,
	HTTP_PATCH,
	HTTP_COPY,
	HTTP_METHOD_COUNT
};

const std::string& httpMethodAsVerb(EHTTPMethod method);
bool isHttpInformationalStatus(S32 status);
bool isHttpGoodStatus(S32 status);
bool isHttpRedirectStatus(S32 status);
bool isHttpClientErrorStatus(S32 status);
bool isHttpServerErrorStatus(S32 status);

// Parses 'Retry-After' header contents and returns seconds until retry should occur.
bool getSecondsUntilRetryAfter(const std::string& retry_after, F32& seconds_to_wait);

//// HTTP Headers /////

// Outgoing headers. Do *not* use these to check incoming headers.
// For incoming headers, use the lower-case headers, below.
extern const std::string HTTP_OUT_HEADER_ACCEPT;
extern const std::string HTTP_OUT_HEADER_ACCEPT_CHARSET;
extern const std::string HTTP_OUT_HEADER_ACCEPT_ENCODING;
extern const std::string HTTP_OUT_HEADER_ACCEPT_LANGUAGE;
extern const std::string HTTP_OUT_HEADER_ACCEPT_RANGES;
extern const std::string HTTP_OUT_HEADER_AGE;
extern const std::string HTTP_OUT_HEADER_ALLOW;
extern const std::string HTTP_OUT_HEADER_AUTHORIZATION;
extern const std::string HTTP_OUT_HEADER_CACHE_CONTROL;
extern const std::string HTTP_OUT_HEADER_CONNECTION;
extern const std::string HTTP_OUT_HEADER_CONTENT_DESCRIPTION;
extern const std::string HTTP_OUT_HEADER_CONTENT_ENCODING;
extern const std::string HTTP_OUT_HEADER_CONTENT_ID;
extern const std::string HTTP_OUT_HEADER_CONTENT_LANGUAGE;
extern const std::string HTTP_OUT_HEADER_CONTENT_LENGTH;
extern const std::string HTTP_OUT_HEADER_CONTENT_LOCATION;
extern const std::string HTTP_OUT_HEADER_CONTENT_MD5;
extern const std::string HTTP_OUT_HEADER_CONTENT_RANGE;
extern const std::string HTTP_OUT_HEADER_CONTENT_TRANSFER_ENCODING;
extern const std::string HTTP_OUT_HEADER_CONTENT_TYPE;
extern const std::string HTTP_OUT_HEADER_COOKIE;
extern const std::string HTTP_OUT_HEADER_DATE;
extern const std::string HTTP_OUT_HEADER_DESTINATION;
extern const std::string HTTP_OUT_HEADER_ETAG;
extern const std::string HTTP_OUT_HEADER_EXPECT;
extern const std::string HTTP_OUT_HEADER_EXPIRES;
extern const std::string HTTP_OUT_HEADER_FROM;
extern const std::string HTTP_OUT_HEADER_HOST;
extern const std::string HTTP_OUT_HEADER_IF_MATCH;
extern const std::string HTTP_OUT_HEADER_IF_MODIFIED_SINCE;
extern const std::string HTTP_OUT_HEADER_IF_NONE_MATCH;
extern const std::string HTTP_OUT_HEADER_IF_RANGE;
extern const std::string HTTP_OUT_HEADER_IF_UNMODIFIED_SINCE;
extern const std::string HTTP_OUT_HEADER_KEEP_ALIVE;
extern const std::string HTTP_OUT_HEADER_LAST_MODIFIED;
extern const std::string HTTP_OUT_HEADER_LOCATION;
extern const std::string HTTP_OUT_HEADER_MAX_FORWARDS;
extern const std::string HTTP_OUT_HEADER_MIME_VERSION;
extern const std::string HTTP_OUT_HEADER_PRAGMA;
extern const std::string HTTP_OUT_HEADER_PROXY_AUTHENTICATE;
extern const std::string HTTP_OUT_HEADER_PROXY_AUTHORIZATION;
extern const std::string HTTP_OUT_HEADER_RANGE;
extern const std::string HTTP_OUT_HEADER_REFERER;
extern const std::string HTTP_OUT_HEADER_RETRY_AFTER;
extern const std::string HTTP_OUT_HEADER_SERVER;
extern const std::string HTTP_OUT_HEADER_SET_COOKIE;
extern const std::string HTTP_OUT_HEADER_TE;
extern const std::string HTTP_OUT_HEADER_TRAILER;
extern const std::string HTTP_OUT_HEADER_TRANSFER_ENCODING;
extern const std::string HTTP_OUT_HEADER_UPGRADE;
extern const std::string HTTP_OUT_HEADER_USER_AGENT;
extern const std::string HTTP_OUT_HEADER_VARY;
extern const std::string HTTP_OUT_HEADER_VIA;
extern const std::string HTTP_OUT_HEADER_WARNING;
extern const std::string HTTP_OUT_HEADER_WWW_AUTHENTICATE;

// Incoming headers are normalized to lower-case.
extern const std::string HTTP_IN_HEADER_ACCEPT_LANGUAGE;
extern const std::string HTTP_IN_HEADER_CACHE_CONTROL;
extern const std::string HTTP_IN_HEADER_CONTENT_LENGTH;
extern const std::string HTTP_IN_HEADER_CONTENT_LOCATION;
extern const std::string HTTP_IN_HEADER_CONTENT_TYPE;
extern const std::string HTTP_IN_HEADER_HOST;
extern const std::string HTTP_IN_HEADER_LOCATION;
extern const std::string HTTP_IN_HEADER_RETRY_AFTER;
extern const std::string HTTP_IN_HEADER_SET_COOKIE;
extern const std::string HTTP_IN_HEADER_USER_AGENT;
extern const std::string HTTP_IN_HEADER_X_FORWARDED_FOR;

//// HTTP Content Types ////

extern const std::string HTTP_CONTENT_LLSD_XML;
extern const std::string HTTP_CONTENT_OCTET_STREAM;
extern const std::string HTTP_CONTENT_VND_LL_MESH;
extern const std::string HTTP_CONTENT_XML;
extern const std::string HTTP_CONTENT_JSON;
extern const std::string HTTP_CONTENT_TEXT_HTML;
extern const std::string HTTP_CONTENT_TEXT_HTML_UTF8;
extern const std::string HTTP_CONTENT_TEXT_PLAIN_UTF8;
extern const std::string HTTP_CONTENT_TEXT_LLSD;
extern const std::string HTTP_CONTENT_TEXT_XML;
extern const std::string HTTP_CONTENT_TEXT_LSL;
extern const std::string HTTP_CONTENT_TEXT_PLAIN;
extern const std::string HTTP_CONTENT_IMAGE_X_J2C;
extern const std::string HTTP_CONTENT_IMAGE_J2C;
extern const std::string HTTP_CONTENT_IMAGE_JPEG;
extern const std::string HTTP_CONTENT_IMAGE_PNG;
extern const std::string HTTP_CONTENT_IMAGE_BMP;

//// HTTP Cache Settings ////
extern const std::string HTTP_NO_CACHE;
extern const std::string HTTP_NO_CACHE_CONTROL;

#endif