Page Speed Optimization Libraries
1.13.35.1
|
#include "domain_rewrite_filter.h"
Public Types | |
enum | RewriteResult { kRewroteDomain, kDomainUnchanged, kFail } |
enum | HeaderSource { kHttp, kMetaHttpEquiv } |
typedef std::vector< std::pair < StringPiece, StringPiece > > | SetCookieAttributes |
Public Types inherited from net_instaweb::HtmlFilter | |
enum | ScriptUsage { kWillInjectScripts, kMayInjectScripts, kNeverInjectsScripts } |
Describes a filter's relationship with scripts. More... | |
Public Member Functions | |
DomainRewriteFilter (RewriteDriver *rewrite_driver, Statistics *stats) | |
virtual void | StartDocumentImpl () |
virtual void | EndDocument () |
virtual void | StartElementImpl (HtmlElement *element) |
virtual void | EndElementImpl (HtmlElement *element) |
virtual const char * | Name () const |
The name of this filter – used for logging and debugging. | |
ScriptUsage | GetScriptUsage () const override |
Public Member Functions inherited from net_instaweb::CommonFilter | |
CommonFilter (RewriteDriver *driver) | |
const GoogleUrl & | base_url () const |
Getters. More... | |
const GoogleUrl & | decoded_base_url () const |
RewriteDriver * | driver () const |
HtmlElement * | noscript_element () const |
void | InsertNodeAtBodyEnd (HtmlNode *data) |
virtual void | StartDocument () |
Note: Don't overload these methods, overload the implementers instead! | |
virtual void | StartElement (HtmlElement *element) |
virtual void | EndElement (HtmlElement *element) |
virtual void | Characters (HtmlCharactersNode *characters) |
ResourcePtr | CreateInputResource (StringPiece input_url, RewriteDriver::InputRole role, bool *is_authorized) |
ResourcePtr | CreateInputResourceOrInsertDebugComment (StringPiece input_url, RewriteDriver::InputRole role, HtmlElement *element) |
void | ResolveUrl (StringPiece input_url, GoogleUrl *out_url) |
bool | IsRelativeUrlLoadPermittedByCsp (StringPiece url, CspDirective role) |
bool | BaseUrlIsValid () const |
bool | DebugMode () const |
bool | CanAddPagespeedOnloadToImage (const HtmlElement &) |
virtual void | LogFilterModifiedContent () |
virtual RewriteDriver::InlineAuthorizationPolicy | AllowUnauthorizedDomain () const |
virtual bool | IntendedForInlining () const |
void | AddJsToElement (StringPiece js, HtmlElement *script) |
Public Member Functions inherited from net_instaweb::EmptyHtmlFilter | |
virtual void | Cdata (HtmlCdataNode *cdata) |
Called for CDATA blocks (e.g. <![CDATA[foobar]]>) | |
virtual void | Comment (HtmlCommentNode *comment) |
Called for HTML comments that aren't IE directives (e.g. ). | |
virtual void | IEDirective (HtmlIEDirectiveNode *directive) |
virtual void | Directive (HtmlDirectiveNode *directive) |
Called for HTML directives (e.g. <!doctype foobar>). | |
virtual void | Flush () |
virtual void | DetermineEnabled (GoogleString *disabled_reason) |
virtual bool | CanModifyUrls () |
ScriptUsage | GetScriptUsage () const override |
Public Member Functions inherited from net_instaweb::HtmlFilter | |
virtual void | RenderDone () |
bool | is_enabled () const |
void | set_is_enabled (bool is_enabled) |
Static Public Member Functions | |
static void | InitStats (Statistics *statistics) |
static RewriteResult | Rewrite (const StringPiece &input_url, const GoogleUrl &base_url, const ServerContext *server_context, const RewriteOptions *options, bool apply_sharding, bool apply_domain_suffix, GoogleString *output_url) |
static void | UpdateDomainHeaders (const GoogleUrl &base_url, const ServerContext *server_context, const RewriteOptions *options, ResponseHeaders *headers) |
static bool | UpdateOneDomainHeader (HeaderSource src, const GoogleUrl &base_url, const ServerContext *server_context, const RewriteOptions *options, StringPiece name, StringPiece value_in, GoogleString *out) |
static bool | UpdateSetCookieHeader (const GoogleUrl &base_url, const ServerContext *server_context, const RewriteOptions *options, StringPiece value_in, GoogleString *out) |
Like UpdateOneDomainHeader, but specifically for Set-Cookie. | |
static bool | ParseRefreshContent (StringPiece input, StringPiece *before, StringPiece *url, StringPiece *after) |
static void | ParseSetCookieAttributes (StringPiece input, StringPiece *cookie_string, SetCookieAttributes *attributes) |
Static Public Member Functions inherited from net_instaweb::CommonFilter | |
static bool | ExtractMetaTagDetails (const HtmlElement &element, const ResponseHeaders *headers, GoogleString *content, GoogleString *mime_type, GoogleString *charset) |
Static Public Attributes | |
static const char | kStickyRedirectHeader [] |
Static Public Attributes inherited from net_instaweb::CommonFilter | |
static const char | kCreateResourceFailedDebugMsg [] |
Debug message to be inserted when resource creation fails. | |
Additional Inherited Members | |
Protected Member Functions inherited from net_instaweb::CommonFilter | |
ServerContext * | server_context () const |
const RewriteOptions * | rewrite_options () |
virtual const char * | LoggingId () |
Filter that rewrites URL domains for resources that are not otherwise rewritten. For example, the user may want to domain-shard adding a hash to their URL leaves, or domain shard resources that are not cacheable.
This will also rewrite hyperlinks and URL-related headers and metas if domain_rewrite_hyperlinks() is on, and also to Set-Cookie headers if domain_rewrite_cookies() is on.
|
virtual |
Note: EndDocument will be called immediately before the last Flush call. (which also means that in the RewriteDriver use it is called before rendering for the last flush window).
Reimplemented from net_instaweb::EmptyHtmlFilter.
|
inlineoverridevirtual |
Injects scripts only when option ClientDomainRewrite is true, and the current document is not AMP.
Implements net_instaweb::HtmlFilter.
|
static |
Tries to parse the content of a Refresh header, returning if successful. *before gets anything before the URL or its opening quotes. *url gets the portion of parse that's the URL itself, and *after gets everything after the URL and its closing quote, if any. Note that this means that reassembling the URL may require addition of new quotes and escaping.
|
static |
Tries to parse the contents of a Set-Cookie header, specified as "input", extracting out the cookie string into *cookie_string and the attribute key value pairs into *attributes. This does not eliminate duplicate attributes; note that the spec requires using the last occurrences. *attributes and *cookie_string are overwritten, not appended to.
|
static |
Rewrites the specified URL (which might be relative to the base tag) into an absolute sharded url.
Absolute URL output_url will be set if kRewroteDomain or kDomainUnchanged returned.
static for use in UpdateLocationHeader.
|
virtual |
Overload these implementer methods: Intentionally left abstract so that implementers don't forget to change the name from Blah to BlahImpl.
Implements net_instaweb::CommonFilter.
|
static |
Update url and domains in headers as per the rewrite rules configured for this domain.
For now this fixes Location:, Refresh:, and Set-Cookie:
static since we may need to do it in Apache with no appropriate RewriteDriver available.
|
static |
Update an indivual header based on domain rewrite rules. Returns true if a change was made, in which case *out should be committed.