Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
net_instaweb::InflatingFetch Class Reference

#include "inflating_fetch.h"

Inheritance diagram for net_instaweb::InflatingFetch:
net_instaweb::SharedAsyncFetch net_instaweb::AsyncFetch net_instaweb::Writer

Public Member Functions

 InflatingFetch (AsyncFetch *fetch)
 
void EnableGzipFromBackend ()
 
- Public Member Functions inherited from net_instaweb::SharedAsyncFetch
 SharedAsyncFetch (AsyncFetch *base_fetch)
 
virtual const RequestContextPtrrequest_context ()
 
- Public Member Functions inherited from net_instaweb::AsyncFetch
 AsyncFetch (const RequestContextPtr &request_ctx)
 
void HeadersComplete ()
 
void Done (bool success)
 
virtual bool Write (const StringPiece &content, MessageHandler *handler)
 
virtual bool Flush (MessageHandler *handler)
 
RequestHeadersrequest_headers ()
 
void set_request_headers (RequestHeaders *headers)
 
void SetRequestHeadersTakingOwnership (RequestHeaders *headers)
 Same as above, but takes ownership.
 
const RequestHeadersrequest_headers () const
 
ResponseHeadersresponse_headers ()
 See doc for request_headers and set_request_headers.
 
void set_response_headers (ResponseHeaders *headers)
 
ResponseHeadersextra_response_headers ()
 
void set_extra_response_headers (ResponseHeaders *headers)
 
bool headers_complete () const
 
bool content_length_known () const
 
int64 content_length () const
 
void set_content_length (int64 x)
 
GoogleString LoggingString ()
 
virtual AbstractLogRecordlog_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 UnGzipValueIfCompressed (const HTTPValue &src, ResponseHeaders *headers, HTTPValue *dest, MessageHandler *handler)
 
static bool GzipValue (int compression_level, const HTTPValue &http_value, HTTPValue *compressed_value, ResponseHeaders *headers, MessageHandler *handler)
 
- Static Public Member Functions inherited from net_instaweb::AsyncFetch
static bool IsGoogleCacheVia (StringPiece via_value)
 

Protected Member Functions

virtual bool HandleWrite (const StringPiece &sp, MessageHandler *handler)
 
virtual void HandleHeadersComplete ()
 
virtual void HandleDone (bool success)
 
virtual void Reset ()
 
- Protected Member Functions inherited from net_instaweb::SharedAsyncFetch
virtual bool HandleFlush (MessageHandler *handler)
 
virtual bool IsCachedResultValid (const ResponseHeaders &headers)
 
virtual bool IsBackgroundFetch () const
 
void PropagateContentLength ()
 Propagates any set_content_length from this to the base fetch.
 

Additional Inherited Members

- Static Public Attributes inherited from net_instaweb::AsyncFetch
static const int kContentLengthUnknown = -1
 

Detailed Description

This Fetch layer helps work with origin servers that serve gzipped content even when request-headers do not include accept-encoding:gzip. In that scenario, this class inflates the content and strips the content-encoding:gzip response header.

Some servers will serve gzipped content even to clients that didn't ask for it. Depending on the serving environment, we may also want to ask backend servers for gzipped content even if we want cleartext to be sent to the Write methods. Users of this class can force this by calling EnableGzipFromBackend.

Member Function Documentation

void net_instaweb::InflatingFetch::EnableGzipFromBackend ( )

Adds accept-encoding:gzip to the request headers sent to the origin. The data is inflated as we Write it. If deflate or gzip was already in the request then this has no effect.

static bool net_instaweb::InflatingFetch::GzipValue ( int  compression_level,
const HTTPValue http_value,
HTTPValue compressed_value,
ResponseHeaders headers,
MessageHandler handler 
)
static

GZip compress HTTPValue, updating the headers reflect the new state, output to compressed_value. Returns true if the value is successfully compressed.

virtual void net_instaweb::InflatingFetch::HandleHeadersComplete ( )
protectedvirtual

Analyzes headers and depending on the request settings and flags will either setup inflater or not.

Reimplemented from net_instaweb::SharedAsyncFetch.

virtual bool net_instaweb::InflatingFetch::HandleWrite ( const StringPiece &  sp,
MessageHandler handler 
)
protectedvirtual

If inflation is required, inflates and passes bytes to the linked fetch, otherwise just passes bytes.

Reimplemented from net_instaweb::SharedAsyncFetch.

virtual void net_instaweb::InflatingFetch::Reset ( )
protectedvirtual

Resets the 'headers_complete_' flag.

Todo:
TODO(jmarantz): should this also clear the response headers?

Reimplemented from net_instaweb::AsyncFetch.

static bool net_instaweb::InflatingFetch::UnGzipValueIfCompressed ( const HTTPValue src,
ResponseHeaders headers,
HTTPValue dest,
MessageHandler handler 
)
static

Inflate a GZipped HTTPValue if it has been gzipped-compressed, updating the headers to reflect the new state. Returns false if the data was not compressed, leaving dest unmodified.

Notes: dest and src should not be the same object. If the unzip fails, you may need to link src into dest.


The documentation for this class was generated from the following file: