Google APIs Client Library for C++
HttpTransport Class Reference

Abstract interface defining an HTTP transport will be specialized for different concrete mechanisms for interacting with HTTP servers. More...

#include "client/transport/http_transport.h"

+ Inheritance diagram for HttpTransport:

List of all members.

Public Member Functions

 HttpTransport (const HttpTransportOptions &options)
 Construct the transport using the provided options.
virtual ~HttpTransport ()
 Starndard destructor.
const string & user_agent () const
 Returns the value of the User-Agent header for this transport instance.
const HttpTransportOptionsoptions () const
 Retrieve the transport options for this instance.
HttpTransportOptionsmutable_options ()
 Get the options to modify this instance.
const HttpRequestOptionsdefault_request_options () const
 Returns the default options used to initialize new HttpRequest instances.
HttpRequestOptionsmutable_default_request_options ()
 Returns modifiable options used to initialize new HttpRequest instances.
void set_id (const StringPiece &id)
 The transport id is used to tag instances for debug/tracing purposes.
const string & id () const
 Returns the instance id for debug/tracing purposes.
void set_scribe (HttpScribe *scribe)
 Sets (or clears) the request scribe.
HttpScribescribe () const
 Returns the bound scribe, if any.
virtual HttpRequestNewHttpRequest (const HttpRequest::HttpMethod &method)=0
 Create a new HttpRequest instance that will use this transport.

Detailed Description

Abstract interface defining an HTTP transport will be specialized for different concrete mechanisms for interacting with HTTP servers.

This is an abstract interface that acts as the base class for all Http Transports used by the Google APIs for C++ runtime library.

It is recommended that you always use this class when defining classes and interfaces rather than the concrete subclasses. It is recommended that you create instances using factory -- either HttpTransportFactory or HttpTransportLayerConfig::NewDefaultTransport() on an HttpTransportLayerConfig instance.

An HttpTransport instance is stateless. It can accomodate multiple outstanding requests to different servers at the same time. There is no technical reason to have multiple instances other than wanting different configurations, such as standard request options.

You must set the HttpTransportOptions::set_cacerts_path() with the path to a file to validate SSL certificates. The SDK provides a "roots.pem" which can validate all the certificates used by Google Cloud Platform servers and other commonly used certificates. To disable SSL verification you can set it to HttpTransportOptions::kDisableSslValidation, though doing so will lose security against some forms of SSL attacks.

See also:
HttpRequest
HttpTransportFactory
HttpTransportLayerConfig
HttpTransportOptions

Constructor & Destructor Documentation

HttpTransport ( const HttpTransportOptions options) [explicit]

Construct the transport using the provided options.

Parameters:
[in]optionsThe options to configure the transport with.

The options will be copied into a local attribute managed by this instance. To make changes once this instance has been constructed use mutable_transport_options().

virtual ~HttpTransport ( ) [virtual]

Starndard destructor.


Member Function Documentation

const HttpRequestOptions& default_request_options ( ) const [inline]

Returns the default options used to initialize new HttpRequest instances.

const string& id ( ) const [inline]

Returns the instance id for debug/tracing purposes.

Returns modifiable options used to initialize new HttpRequest instances.

Changing the options will affect new requests created but will not affect any existing requests.

Get the options to modify this instance.

Changing the result options will affect the configuration of this instance but might not have effect on existing requests.

virtual HttpRequest* NewHttpRequest ( const HttpRequest::HttpMethod method) [pure virtual]

Create a new HttpRequest instance that will use this transport.

This method is the HttpRequest factory. It is the preferred (and often only) way to instantiate a request.

Returns:
a new HttpRequest

Implemented in JsonPlaybackTransport, and CurlHttpTransport.

const HttpTransportOptions& options ( ) const [inline]

Retrieve the transport options for this instance.

HttpScribe* scribe ( ) const [inline]

Returns the bound scribe, if any.

Returns:
NULL if no scribe is bound.
void set_id ( const StringPiece &  id) [inline]

The transport id is used to tag instances for debug/tracing purposes.

The default convention is to use simply the type of transport (ie 'curl').

void set_scribe ( HttpScribe scribe) [inline]

Sets (or clears) the request scribe.

Scribes incur significant overhead so are not indended for production use. They are for debugging, testing, and diagnostics.

Parameters:
[in]scribeThe caller maintains ownership. NULL clears the scribe.
const string& user_agent ( ) const [inline]

Returns the value of the User-Agent header for this transport instance.

To change the value, modify the options.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines