15 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_QUERY_H_
16 #define NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_QUERY_H_
18 #include "net/instaweb/rewriter/public/device_properties.h"
19 #include "net/instaweb/http/public/request_context.h"
29 namespace net_instaweb {
33 class RequestProperties;
34 class ResponseHeaders;
36 class RewriteDriverFactory;
45 static const char kPageSpeed[];
46 static const char kModPagespeedFilters[];
47 static const char kPageSpeedFilters[];
89 Status
Scan(
bool allow_related_options,
90 bool allow_options_to_be_specified_by_cookies,
107 template <
class HeaderT>
128 const QueryParams& query_params()
const {
return query_params_; }
129 const QueryParams& pagespeed_query_params()
const {
130 return pagespeed_query_params_;
132 const QueryParams& pagespeed_option_cookies()
const {
133 return pagespeed_option_cookies_;
135 const RewriteOptions* options()
const {
return options_.get(); }
136 RewriteOptions* ReleaseOptions() {
return options_.release(); }
140 static bool IsOK(Status status) {
141 return (status == kNoneFound) || (status == kSuccess);
145 friend class RewriteQueryTest;
146 FRIEND_TEST(RewriteQueryTest, ClientOptionsEmptyHeader);
147 FRIEND_TEST(RewriteQueryTest, ClientOptionsMultipleHeaders);
148 FRIEND_TEST(RewriteQueryTest, ClientOptionsOrder1);
149 FRIEND_TEST(RewriteQueryTest, ClientOptionsOrder2);
150 FRIEND_TEST(RewriteQueryTest, ClientOptionsCaseInsensitive);
151 FRIEND_TEST(RewriteQueryTest, ClientOptionsNonDefaultProxyMode);
152 FRIEND_TEST(RewriteQueryTest, ClientOptionsValidVersionBadOptions);
153 FRIEND_TEST(RewriteQueryTest, ClientOptionsInvalidVersion);
159 kProxyModeNoImageTransform,
162 kProxyModeNoTransform,
168 static bool MayHaveCustomOptions(
169 const QueryParams& params,
const RequestHeaders* req_headers,
170 const ResponseHeaders* resp_headers,
171 const RequestHeaders::CookieMultimap& cookies);
174 template <
class HeaderT>
175 static bool HeadersMayHaveCustomOptions(
const QueryParams& params,
176 const HeaderT* headers);
179 static bool CookiesMayHaveCustomOptions(
180 const RequestHeaders::CookieMultimap& cookies);
183 static Status ScanNameValue(
const StringPiece& name,
184 const StringPiece& value,
186 const RequestContextPtr& request_context,
187 RequestProperties* request_properties,
188 RewriteOptions* options,
189 MessageHandler* handler);
192 static Status ParseResourceOption(StringPiece value, RewriteOptions* options,
193 const RewriteFilter* rewrite_filter);
197 static bool ParseClientOptions(
198 const StringPiece& client_options,
199 ProxyMode* proxy_mode,
204 static bool SetEffectiveImageQualities(
206 RequestProperties* request_properties,
207 RewriteOptions* options);
210 static bool UpdateRewriteOptionsWithClientOptions(
211 StringPiece header_value, RequestProperties* request_properties,
212 RewriteOptions* options);
215 static bool ParseProxyMode(
const GoogleString* mode_name, ProxyMode* mode);
218 static bool ParseImageQualityPreference(
222 QueryParams query_params_;
223 QueryParams pagespeed_query_params_;
224 QueryParams pagespeed_option_cookies_;
225 scoped_ptr<RewriteOptions> options_;
class GoogleUrl
Definition: google_url.h:58
static const char kModPagespeed[]
The names of query-params.
Definition: rewrite_query.h:44
Parses and rewrites URL query parameters.
Definition: query_params.h:31
ImageQualityPreference
Definition: device_properties.h:69
Definition: rewrite_query.h:41
static Status ScanHeader(bool allow_options, const GoogleString &request_option_override, const RequestContextPtr &request_context, HeaderT *headers, RequestProperties *request_properties, RewriteOptions *options, MessageHandler *handler)
static GoogleString GenerateResourceOption(StringPiece filter_id, RewriteDriver *driver)
static const char kNoscriptValue[]
Definition: rewrite_query.h:52
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
static bool IsOK(Status status)
Definition: rewrite_query.h:140
Definition: rewrite_driver.h:100
Definition: server_context.h:99
Definition: message_handler.h:39
Status Scan(bool allow_related_options, bool allow_options_to_be_specified_by_cookies, const GoogleString &request_option_override, const RequestContextPtr &request_context, RewriteDriverFactory *factory, ServerContext *server_context, GoogleUrl *request_url, RequestHeaders *request_headers, ResponseHeaders *response_headers, MessageHandler *handler)
static bool MightBeCustomOption(StringPiece name)
Definition: rewrite_options.h:84
Definition: request_properties.h:37
Definition: rewrite_driver_factory.h:70