Page Speed Optimization Libraries
1.13.35.1
|
#include "mock_url_fetcher.h"
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 GoogleString & | last_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 |
AsyncFetch * | EnableInflation (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 () | |
Simple UrlFetcher meant for tests, you can set responses for individual URLs. Meant only for testing.
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.
|
inline |
When disabled, fetcher will fail (but not crash) for all requests. Use to simulate temporarily not having access to resources, for example.
|
inline |
If set to true (defaults to false) the fetcher will fail after outputting the headers. See also SetResponseFailure which fails after writing the body.
|
inline |
Set to false if you don't want the fetcher to EXPECT fail on unfound URL. Useful in MockUrlFetcher unittest :)
|
inline |
If set to true (defaults to false) the fetcher will not emit writes of length 0.
|
inline |
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.
|
inline |
Update response header's Date using supplied timer. Note: Must set_timer().
|
inline |
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.
|
inlinevirtual |
Determine if the fetcher supports fetching using HTTPS. By default we assume a fetcher can.
Reimplemented from net_instaweb::UrlAsyncFetcher.