~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/pagespeed/kernel/http/http_names.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2010 Google 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
 
// Author: jmarantz@google.com (Joshua Marantz)
18
 
//
19
 
// String and numeric constants for common HTTP Attributes & status codes.
20
 
 
21
 
#ifndef PAGESPEED_KERNEL_HTTP_HTTP_NAMES_H_
22
 
#define PAGESPEED_KERNEL_HTTP_HTTP_NAMES_H_
23
 
 
24
 
#include "pagespeed/kernel/base/string_util.h"
25
 
 
26
 
namespace net_instaweb {
27
 
 
28
 
// Global constants for common HTML attributes names and values.
29
 
//
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[];
103
 
 
104
 
  // A request header for client to specify client options.
105
 
  static const char kXPsaClientOptions[];
106
 
 
107
 
  // This header indicates to the distributed task that it should not timeout
108
 
  // its rewrite.
109
 
  static const char kXPsaDistributedRewriteBlock[];
110
 
 
111
 
  // This header is set in distributed rewrite requests that originated from
112
 
  // fetch requests (.pagespeed. and IPRO).
113
 
  static const char kXPsaDistributedRewriteFetch[];
114
 
 
115
 
  // This header is set in distributed rewrite requests that originated from
116
 
  // HTML requests (HTML and nested filters).
117
 
  static const char kXPsaDistributedRewriteForHtml[];
118
 
 
119
 
  // This header is set on optional fetches that got dropped due to load.
120
 
  static const char kXPsaLoadShed[];
121
 
 
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[];
126
 
 
127
 
  // This header is set in a distributed rewrite task to ask for metadata
128
 
  // in the response.
129
 
  static const char kXPsaRequestMetadata[];
130
 
 
131
 
  // This header is set in a distributed rewrite response and the value
132
 
  // is the serialized metadata.
133
 
  static const char kXPsaResponseMetadata[];
134
 
 
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[];
141
 
 
142
 
  static const char kXRequestedWith[];
143
 
 
144
 
  // This header is set on optimized responses to indicate the original
145
 
  // content length.
146
 
  static const char kXOriginalContentLength[];
147
 
  static const char kXUACompatible[];
148
 
 
149
 
  // The config to be used fo the split html xpath.
150
 
  static const char kXPsaSplitConfig[];
151
 
 
152
 
  // Sendfile type responses.
153
 
  static const char kXSendfile[];
154
 
  static const char kXAccelRedirect[];
155
 
 
156
 
  // Gets a sorted StringPieceVector containing all the hop-by-hop headers,
157
 
  // plus Set-Cookie and Set-Cookie2, per
158
 
  //
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();
165
 
 
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();
173
 
};
174
 
 
175
 
namespace HttpStatus {
176
 
// Http status codes.
177
 
// Grokked from http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
178
 
enum Code {
179
 
  kContinue = 100,
180
 
  kSwitchingProtocols = 101,
181
 
 
182
 
  kOK = 200,
183
 
  kCreated = 201,
184
 
  kAccepted = 202,
185
 
  kNonAuthoritative = 203,
186
 
  kNoContent = 204,
187
 
  kResetContent = 205,
188
 
  kPartialContent = 206,
189
 
 
190
 
  kMultipleChoices = 300,
191
 
  kMovedPermanently = 301,
192
 
  kFound = 302,
193
 
  kSeeOther = 303,
194
 
  kNotModified = 304,
195
 
  kUseProxy = 305,
196
 
  kSwitchProxy = 306,  // In old spec; no longer used.
197
 
  kTemporaryRedirect = 307,
198
 
 
199
 
  kBadRequest = 400,
200
 
  kUnauthorized = 401,
201
 
  kPaymentRequired = 402,
202
 
  kForbidden = 403,
203
 
  kNotFound = 404,
204
 
  kMethodNotAllowed = 405,
205
 
  kNotAcceptable = 406,
206
 
  kProxyAuthRequired = 407,
207
 
  kRequestTimeout = 408,
208
 
  kConflict = 409,
209
 
  kGone = 410,
210
 
  kLengthRequired = 411,
211
 
  kPreconditionFailed = 412,
212
 
  kEntityTooLarge = 413,
213
 
  kUriTooLong = 414,
214
 
  kUnsupportedMediaType = 415,
215
 
  kRangeNotSatisfiable = 416,
216
 
  kExpectationFailed = 417,
217
 
  kImATeapot = 418,
218
 
 
219
 
  kInternalServerError = 500,
220
 
  kNotImplemented = 501,
221
 
  kBadGateway = 502,
222
 
  kUnavailable = 503,
223
 
  kGatewayTimeout = 504,
224
 
  kHttpVersionNotSupported = 505,
225
 
 
226
 
  // Instaweb-specific proxy failure constants.
227
 
  kProxyPublisherFailure = 520,
228
 
  kProxyFailure = 521,
229
 
  kProxyConfigurationFailure = 522,
230
 
  kProxyDeclinedRequest = 523,
231
 
  kProxyDnsLookupFailure = 524,
232
 
 
233
 
  // PSOL-specific response code to indiciate that a distributed connection
234
 
  // failed.
235
 
  kDistributedConnectionFailure = 550,
236
 
 
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
242
 
  // cacheable.
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,
251
 
};
252
 
 
253
 
// Transform a status code into the equivalent reason phrase.
254
 
const char* GetReasonPhrase(Code rc);
255
 
 
256
 
}  // namespace HttpStatus
257
 
 
258
 
}  // namespace net_instaweb
259
 
 
260
 
#endif  // PAGESPEED_KERNEL_HTTP_HTTP_NAMES_H_