2
* Copyright 2010 Google Inc.
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
17
// Author: jmarantz@google.com (Joshua Marantz)
19
// String and numeric constants for common HTTP Attributes & status codes.
21
#ifndef PAGESPEED_KERNEL_HTTP_HTTP_NAMES_H_
22
#define PAGESPEED_KERNEL_HTTP_HTTP_NAMES_H_
24
#include "pagespeed/kernel/base/string_util.h"
26
namespace net_instaweb {
28
// Global constants for common HTML attributes names and values.
30
// TODO(jmarantz): Proactively change all the occurrences of the static strings
31
// to use these shared constants.
32
struct HttpAttributes {
33
static const char kAccept[];
34
static const char kAcceptEncoding[];
35
static const char kAccessControlAllowOrigin[];
36
static const char kAccessControlAllowCredentials[];
37
static const char kAge[];
38
static const char kAllow[];
39
static const char kAttachment[];
40
static const char kAuthorization[];
41
static const char kCacheControl[];
42
static const char kConnection[];
43
static const char kContentEncoding[];
44
static const char kContentDisposition[];
45
static const char kContentLanguage[];
46
static const char kContentLength[];
47
static const char kContentType[];
48
static const char kCookie[];
49
static const char kCookie2[];
50
static const char kDate[];
51
static const char kDeflate[];
52
static const char kDnt[];
53
static const char kEtag[];
54
static const char kExpires[];
55
static const char kGzip[];
56
static const char kHost[];
57
static const char kIfModifiedSince[];
58
static const char kIfNoneMatch[];
59
static const char kKeepAlive[];
60
static const char kLastModified[];
61
static const char kLocation[];
62
static const char kMaxAge[];
63
static const char kNoCache[];
64
static const char kNoCacheMaxAge0[];
65
static const char kNoStore[];
66
static const char kNosniff[];
67
static const char kOrigin[];
68
static const char kPragma[];
69
static const char kPrivate[];
70
static const char kProxyAuthenticate[];
71
static const char kProxyAuthorization[];
72
static const char kPublic[];
73
static const char kPurpose[];
74
static const char kReferer[]; // sic
75
static const char kServer[];
76
static const char kSetCookie[];
77
static const char kSetCookie2[];
78
static const char kTE[];
79
static const char kTrailers[];
80
static const char kTransferEncoding[];
81
static const char kUpgrade[];
82
static const char kUserAgent[];
83
static const char kVary[];
84
static const char kVia[];
85
static const char kWarning[];
86
static const char kXmlHttpRequest[];
87
static const char kXAssociatedContent[];
88
static const char kXContentTypeOptions[];
89
static const char kXForwardedFor[];
90
static const char kXForwardedProto[];
91
static const char kXGooglePagespeedClientId[];
92
static const char kXGoogleRequestEventId[];
93
// If this header's value matches the configured blocking rewrite key, then
94
// all rewrites are completed before the response is sent to the client.
95
static const char kXPsaBlockingRewrite[];
96
// This header determines how the blocking rewrite will behave; will it wait
97
// for async events or not.
98
static const char kXPsaBlockingRewriteMode[];
99
// Value of the kXPsaBlockingRewriteMode header which makes the blocking
100
// rewrite wait for async events.
101
// TODO(bharathbhushan): Does this belong somewhere else?
102
static const char kXPsaBlockingRewriteModeSlow[];
104
// A request header for client to specify client options.
105
static const char kXPsaClientOptions[];
107
// This header indicates to the distributed task that it should not timeout
109
static const char kXPsaDistributedRewriteBlock[];
111
// This header is set in distributed rewrite requests that originated from
112
// fetch requests (.pagespeed. and IPRO).
113
static const char kXPsaDistributedRewriteFetch[];
115
// This header is set in distributed rewrite requests that originated from
116
// HTML requests (HTML and nested filters).
117
static const char kXPsaDistributedRewriteForHtml[];
119
// This header is set on optional fetches that got dropped due to load.
120
static const char kXPsaLoadShed[];
122
// If this header is present on an incoming request it will be treated as if
123
// it came over a SPDY connection for purposes of applying special
124
// configuration or optimizations.
125
static const char kXPsaOptimizeForSpdy[];
127
// This header is set in a distributed rewrite task to ask for metadata
129
static const char kXPsaRequestMetadata[];
131
// This header is set in a distributed rewrite response and the value
132
// is the serialized metadata.
133
static const char kXPsaResponseMetadata[];
135
// This url param is set when request for the below the fold chunk of the
136
// split html response.
137
static const char kXSplit[];
138
// Values of kXSplit url param for requesting parts of the split html content.
139
static const char kXSplitAboveTheFold[];
140
static const char kXSplitBelowTheFold[];
142
static const char kXRequestedWith[];
144
// This header is set on optimized responses to indicate the original
146
static const char kXOriginalContentLength[];
147
static const char kXUACompatible[];
149
// The config to be used fo the split html xpath.
150
static const char kXPsaSplitConfig[];
152
// Sendfile type responses.
153
static const char kXSendfile[];
154
static const char kXAccelRedirect[];
156
// Gets a sorted StringPieceVector containing all the hop-by-hop headers,
157
// plus Set-Cookie and Set-Cookie2, per
159
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
160
// Note: The returned vector contains NULL-terminated char* entries but
161
// returning it via StringPieceVector causes us to lose this guarantee and we
162
// end up creating temporary GoogleStrings to convert these back to char*.
163
// This performance overhead might be revisited if considered important.
164
static StringPieceVector SortedHopByHopHeaders();
166
// Gets a StringPieceVector containing the caching-related headers that should
167
// be removed from responses.
168
// Note: The returned vector contains NULL-terminated char* entries but
169
// returning it via StringPieceVector causes us to lose this guarantee and we
170
// end up creating temporary GoogleStrings to convert these back to char*.
171
// This performance overhead might be revisited if considered important.
172
static StringPieceVector CachingHeadersToBeRemoved();
175
namespace HttpStatus {
176
// Http status codes.
177
// Grokked from http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
180
kSwitchingProtocols = 101,
185
kNonAuthoritative = 203,
188
kPartialContent = 206,
190
kMultipleChoices = 300,
191
kMovedPermanently = 301,
196
kSwitchProxy = 306, // In old spec; no longer used.
197
kTemporaryRedirect = 307,
201
kPaymentRequired = 402,
204
kMethodNotAllowed = 405,
205
kNotAcceptable = 406,
206
kProxyAuthRequired = 407,
207
kRequestTimeout = 408,
210
kLengthRequired = 411,
211
kPreconditionFailed = 412,
212
kEntityTooLarge = 413,
214
kUnsupportedMediaType = 415,
215
kRangeNotSatisfiable = 416,
216
kExpectationFailed = 417,
219
kInternalServerError = 500,
220
kNotImplemented = 501,
223
kGatewayTimeout = 504,
224
kHttpVersionNotSupported = 505,
226
// Instaweb-specific proxy failure constants.
227
kProxyPublisherFailure = 520,
229
kProxyConfigurationFailure = 522,
230
kProxyDeclinedRequest = 523,
231
kProxyDnsLookupFailure = 524,
233
// PSOL-specific response code to indiciate that a distributed connection
235
kDistributedConnectionFailure = 550,
237
// Instaweb-specific response codes: these are intentionally chosen to be
238
// outside the normal HTTP range, but we consider these response codes
239
// to be 'cacheable' in our own cache.
240
kRememberFetchFailedStatusCode = 10001,
241
// Note that this includes all non-200 status code responses that are not
243
kRememberNotCacheableStatusCode = 10002,
244
// This includes all 200 status code responses that are not cacheable.
245
kRememberNotCacheableAnd200StatusCode = 10003,
246
// Status code used when the actual status code of the response is unknown at
247
// the time of ProxyFetchPropertyCallbackCollector::Detach().
248
kUnknownStatusCode = 10004,
249
// We do not allow caching empty resources. Remember that.
250
kRememberEmptyStatusCode = 10005,
253
// Transform a status code into the equivalent reason phrase.
254
const char* GetReasonPhrase(Code rc);
256
} // namespace HttpStatus
258
} // namespace net_instaweb
260
#endif // PAGESPEED_KERNEL_HTTP_HTTP_NAMES_H_