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

#include "apache_fetch.h"

Inheritance diagram for net_instaweb::ApacheFetch:
net_instaweb::AsyncFetch net_instaweb::Writer

Public Member Functions

 ApacheFetch (const GoogleString &mapped_url, StringPiece debug_info, RewriteDriver *driver, ApacheWriter *apache_writer, RequestHeaders *request_headers, const RequestContextPtr &request_context, const RewriteOptions *options, MessageHandler *handler)
 
void set_handle_error (bool x)
 
void set_buffered (bool x)
 
void Wait () LOCKS_EXCLUDED(scheduler_-> mutex())
 Blocks waiting for the fetch to complete.
 
bool status_ok () const
 
virtual bool IsCachedResultValid (const ResponseHeaders &headers) LOCKS_EXCLUDED(scheduler_-> mutex())
 
void set_is_proxy (bool x)
 
- 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)
 
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 RequestContextPtrrequest_context ()
 
virtual AbstractLogRecordlog_record ()
 
void FixCacheControlForGoogleCache ()
 
- Public Member Functions inherited from net_instaweb::Writer
virtual bool Dump (Writer *writer, MessageHandler *message_handler)
 

Protected Member Functions

virtual void HandleHeadersComplete () LOCKS_EXCLUDED(scheduler_-> mutex())
 
virtual void HandleDone (bool success) LOCKS_EXCLUDED(scheduler_-> mutex())
 
virtual bool HandleFlush (MessageHandler *handler) LOCKS_EXCLUDED(scheduler_-> mutex())
 
virtual bool HandleWrite (const StringPiece &sp, MessageHandler *handler) LOCKS_EXCLUDED(scheduler_-> mutex())
 

Additional Inherited Members

- Static Public Member Functions inherited from net_instaweb::AsyncFetch
static bool IsGoogleCacheVia (StringPiece via_value)
 
- Static Public Attributes inherited from net_instaweb::AsyncFetch
static const int kContentLengthUnknown = -1
 

Detailed Description

Links an apache request_rec* to an AsyncFetch, adding the ability to block based on a condition variable.

If you need this to stream writes and flushes out to apache, call set_buffered(false) and make sure all calls are on the request thread. ApacheWriter will DCHECK-fail if it's called on another thread.

Constructor & Destructor Documentation

net_instaweb::ApacheFetch::ApacheFetch ( const GoogleString mapped_url,
StringPiece  debug_info,
RewriteDriver driver,
ApacheWriter apache_writer,
RequestHeaders request_headers,
const RequestContextPtr request_context,
const RewriteOptions options,
MessageHandler handler 
)

Takes ownership of apache_writer, but the underlying request_rec needs to stay around until Wait returns false or the caller finishes handling a true return and deletes the ApacheFetch. Also takes ownership of request_headers.

Member Function Documentation

virtual bool net_instaweb::ApacheFetch::IsCachedResultValid ( const ResponseHeaders headers) -> mutex())
virtual

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.

Todo:
TODO(nikhilmadan): Consider making this virtual so that subclass authors are forced to look at this function.

Reimplemented from net_instaweb::AsyncFetch.

void net_instaweb::ApacheFetch::set_buffered ( bool  x)
inline

If all calls to an ApacheFetch are on the apache request thread it is safe to set buffered to false. All calls Write()/Flush() will be passed through to the underlying writer immediately. Otherwise, leave it as true and they will be delayed until Wait().

void net_instaweb::ApacheFetch::set_handle_error ( bool  x)
inline

When used for in-place resource optimization in mod_pagespeed, we have disabled fetching resources that are not in cache, otherwise we may wind up doing a loopback fetch to the same Apache server. So the CacheUrlAsyncFetcher will return a 501 or 404 but we do not want to send that to the client. So for ipro we suppress reporting errors in this flow.

Todo:
TODO(jmarantz): consider allowing serf fetches in ipro when running as a reverse-proxy.
void net_instaweb::ApacheFetch::set_is_proxy ( bool  x)
inline

By default ApacheFetch is not intended for proxying third party content. When it is to be used for proxying third party content, we must avoid sending a 'nosniff' header.


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