Page Speed Optimization Libraries
1.13.35.1
|
#include "async_fetch.h"
Public Member Functions | |
AsyncFetch (const RequestContextPtr &request_ctx) | |
void | HeadersComplete () |
void | Done (bool success) |
virtual bool | Write (const StringPiece &content, MessageHandler *handler) |
virtual bool | Flush (MessageHandler *handler) |
virtual bool | IsCachedResultValid (const ResponseHeaders &headers) |
RequestHeaders * | request_headers () |
void | set_request_headers (RequestHeaders *headers) |
void | SetRequestHeadersTakingOwnership (RequestHeaders *headers) |
Same as above, but takes ownership. | |
const RequestHeaders * | request_headers () const |
ResponseHeaders * | response_headers () |
See doc for request_headers and set_request_headers. | |
void | set_response_headers (ResponseHeaders *headers) |
ResponseHeaders * | extra_response_headers () |
void | set_extra_response_headers (ResponseHeaders *headers) |
virtual bool | IsBackgroundFetch () const |
virtual void | Reset () |
bool | headers_complete () const |
bool | content_length_known () const |
int64 | content_length () const |
void | set_content_length (int64 x) |
GoogleString | LoggingString () |
virtual const RequestContextPtr & | request_context () |
virtual AbstractLogRecord * | log_record () |
void | FixCacheControlForGoogleCache () |
Public Member Functions inherited from net_instaweb::Writer | |
virtual bool | Dump (Writer *writer, MessageHandler *message_handler) |
Static Public Member Functions | |
static bool | IsGoogleCacheVia (StringPiece via_value) |
Static Public Attributes | |
static const int | kContentLengthUnknown = -1 |
Protected Member Functions | |
virtual bool | HandleWrite (const StringPiece &sp, MessageHandler *handler)=0 |
virtual bool | HandleFlush (MessageHandler *handler)=0 |
virtual void | HandleDone (bool success)=0 |
virtual void | HandleHeadersComplete ()=0 |
Abstract base class for encapsulating streaming, asynchronous HTTP fetches.
If you want to fetch a resources, implement this interface, create an instance and call UrlAsyncFetcher::Fetch() with it.
It combines the 3 callbacks we expect to get from fetchers (Write, Flush and Done) and adds a HeadersComplete indicator that is useful in any place where we want to deal with and send headers before Write or Done are called.
Note that it automatically invokes HeadersComplete before the first call to Write, Flush or Done.
|
inline |
Keep track of whether the content-length is known before the body is sent, so that a server can decide whether it needs chunked.
Note that this is not necessarily the same as the Content-Length attribute in the response-headers, which might reflect pre-optimized or pre-compressed sizes.
void net_instaweb::AsyncFetch::Done | ( | bool | success | ) |
Fetch complete. This interface is intended for callers (e.g. Fetchers). Implementors must override HandleDone.
ResponseHeaders* net_instaweb::AsyncFetch::extra_response_headers | ( | ) |
Returns extra response headers which may be modified between calls to HeadersComplete() and Done(). This is used to allow a fetch to provide additional headers which cannot be determined when HeadersComplete() has been invoked, e.g., X-Original-Content-Length. This is needed because it is not safe for the producer to modify response_headers() once HeadersComplete() has been called.
void net_instaweb::AsyncFetch::FixCacheControlForGoogleCache | ( | ) |
Determines whether the specified request-headers imply that the server is running in a context where an explicit cache-control "public" header is needed to make caching work, and adds that header if needed.
void net_instaweb::AsyncFetch::HeadersComplete | ( | ) |
Called when ResponseHeaders have been set, but before writing contents. Contract: Must be called (at most once) before Write, Flush or Done. Automatically invoked (if neccessary) before the first call to Write, Flush, or Done. This interface is intended for callers (e.g. Fetchers). Implementors of the AsyncFetch interface must override HandleHeadersComplete.
|
inlinevirtual |
Indicates whether the request is a background fetch. These can be scheduled differently by the fetcher.
Reimplemented in net_instaweb::SharedAsyncFetch.
|
inlinevirtual |
Is the cache entry corresponding to headers valid? Default is that it is valid. Sub-classes can provide specific implementations, e.g., based on cache invalidation timestamp in domain specific options. Used by CacheUrlAsyncFetcher.
Reimplemented in net_instaweb::ProxyFetch, net_instaweb::SharedAsyncFetch, net_instaweb::ApacheFetch, net_instaweb::SimpleBufferedApacheFetch, and net_instaweb::NotifyingFetch.
|
static |
Determines whether the specified via header value matches the expected pattern for the Via header provided by the Google Cloud CDN to services running inside it.
|
virtual |
Returns a pointer to a log record that wraps this fetch's logging info.
GoogleString net_instaweb::AsyncFetch::LoggingString | ( | ) |
Returns logging information in a string eg. c1:0;c2:2;hf:45;. c1 is cache 1, c2 is cache 2, hf is headers fetch.
|
inlinevirtual |
Returns the request context associated with this fetch, if any, or NULL if no request context exists.
Reimplemented in net_instaweb::SharedAsyncFetch.
RequestHeaders* net_instaweb::AsyncFetch::request_headers | ( | ) |
Returns a pointer to the request-headers, lazily constructing them if needed. If they are constructed here (as opposed to being set with set_request_headers) then they will be owned by the class instance.
const RequestHeaders* net_instaweb::AsyncFetch::request_headers | ( | ) | const |
Returns the request_headers as a const pointer: it is required that the RequestHeaders be pre-initialized via non-const request_headers() or via set_request_headers before calling this.
|
inlinevirtual |
Resets the 'headers_complete_' flag.
Reimplemented in net_instaweb::StringAsyncFetch, and net_instaweb::InflatingFetch.
void net_instaweb::AsyncFetch::set_request_headers | ( | RequestHeaders * | headers | ) |
Sets the request-headers to the specifid pointer. The caller must guarantee that the pointed-to headers remain valid as long as the AsyncFetch is running.
Does not take ownership of headers.
|
virtual |
Data available. This interface is intended for callers. Implementors must override HandlerWrite and HandleFlush.
Implements net_instaweb::Writer.