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

#include "mock_url_fetcher.h"

Inheritance diagram for net_instaweb::MockUrlFetcher:

Public Member Functions

void SetResponse (const StringPiece &url, const ResponseHeaders &response_header, const StringPiece &response_body)
void AddToResponse (const StringPiece &url, const StringPiece &name, const StringPiece &value)
void SetConditionalResponse (const StringPiece &url, int64 last_modified_date, const GoogleString &etag, const ResponseHeaders &response_header, const StringPiece &response_body)
virtual void Fetch (const GoogleString &url, MessageHandler *message_handler, AsyncFetch *fetch)
 Fetching unset URLs will cause EXPECT failures as well as Done(false).
virtual bool SupportsHttps () const
void set_fetcher_supports_https (bool supports_https)
const GoogleStringlast_referer ()
 Return the referer of this fetching request.
void SetResponseFailure (const StringPiece &url)
void Clear ()
 Clear all set responses.
void RemoveResponse (const StringPiece &url)
 Remove a single response. Will be a no-op if no response was set for url.
void Disable ()
void Enable ()
void set_fail_on_unexpected (bool x)
void set_update_date_headers (bool x)
void set_omit_empty_writes (bool x)
void set_fail_after_headers (bool x)
void set_verify_host_header (bool x)
void set_verify_pagespeed_header_off (bool x)
void set_timer (Timer *timer)
void set_split_writes (bool val)
void set_error_message (const GoogleString &msg)
 If this is non-empty, we will write this out any time we report an error.
void set_strip_query_params (bool strip_query_params)
- Public Member Functions inherited from net_instaweb::UrlAsyncFetcher
virtual int64 timeout_ms ()
virtual void ShutDown ()
void set_fetch_with_gzip (bool x)
bool fetch_with_gzip () const
AsyncFetchEnableInflation (AsyncFetch *fetch) const

Additional Inherited Members

- Static Public Attributes inherited from net_instaweb::UrlAsyncFetcher
static const int64 kUnspecifiedTimeout
- Protected Member Functions inherited from net_instaweb::UrlAsyncFetcher
 UrlAsyncFetcher ()

Detailed Description

Simple UrlFetcher meant for tests, you can set responses for individual URLs. Meant only for testing.

Member Function Documentation

void net_instaweb::MockUrlFetcher::AddToResponse ( const StringPiece &  url,
const StringPiece &  name,
const StringPiece &  value 

Adds a new response-header attribute name/value pair to an existing response. If the response does not already exist, the method check-fails.

void net_instaweb::MockUrlFetcher::Disable ( )

When disabled, fetcher will fail (but not crash) for all requests. Use to simulate temporarily not having access to resources, for example.

void net_instaweb::MockUrlFetcher::set_fail_after_headers ( bool  x)

If set to true (defaults to false) the fetcher will fail after outputting the headers. See also SetResponseFailure which fails after writing the body.

void net_instaweb::MockUrlFetcher::set_fail_on_unexpected ( bool  x)

Set to false if you don't want the fetcher to EXPECT fail on unfound URL. Useful in MockUrlFetcher unittest :)

void net_instaweb::MockUrlFetcher::set_omit_empty_writes ( bool  x)

If set to true (defaults to false) the fetcher will not emit writes of length 0.

void net_instaweb::MockUrlFetcher::set_split_writes ( bool  val)

If true then each time the fetcher writes it will split the write in half and write each half separately. This is needed to test that Ajax's RecordingFetch caches writes properly and recovers from failure.

void net_instaweb::MockUrlFetcher::set_update_date_headers ( bool  x)

Update response header's Date using supplied timer. Note: Must set_timer().

void net_instaweb::MockUrlFetcher::set_verify_host_header ( bool  x)

If set to true (defaults to false) the fetcher will verify that the Host: header is present, and matches the host/port of the requested URL.

void net_instaweb::MockUrlFetcher::SetConditionalResponse ( const StringPiece &  url,
int64  last_modified_date,
const GoogleString etag,
const ResponseHeaders response_header,
const StringPiece &  response_body 

Set a conditional response which will either respond with the supplied response_headers and response_body or a simple 304 Not Modified depending upon last_modified_time and conditional GET "If-Modified-Since" headers.

void net_instaweb::MockUrlFetcher::SetResponseFailure ( const StringPiece &  url)

Indicates that the specified URL should respond with headers and data, but still return a 'false' status. This is similar to a live fetcher that times out or disconnects while streaming data.

This differs from set_fail_after_headers in that it's specific to a URL, and writes the body first before returning failure.

virtual bool net_instaweb::MockUrlFetcher::SupportsHttps ( ) const

Determine if the fetcher supports fetching using HTTPS. By default we assume a fetcher can.

Reimplemented from net_instaweb::UrlAsyncFetcher.

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