Crashpad
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
crashpad::HTTPTransport Class Referenceabstract

HTTPTransport executes a HTTP request using the specified URL, HTTP method, headers, and body. This class can only issue a synchronous HTTP request. More...

#include "util/net/http_transport.h"

Public Member Functions

void SetURL (const std::string &url)
 Sets URL to which the request will be made. More...
 
void SetMethod (const std::string &http_method)
 Sets the HTTP method to execute. E.g., GET, POST, etc. The default method is "POST". More...
 
void SetHeader (const std::string &header, const std::string &value)
 Sets a HTTP header-value pair. More...
 
void SetBodyStream (std::unique_ptr< HTTPBodyStream > stream)
 Sets the stream object from which to generate the HTTP body. More...
 
void SetTimeout (double timeout)
 Sets the timeout for the HTTP request. The default is 15 seconds. More...
 
void SetRootCACertificatePath (const base::FilePath &cert)
 Sets a certificate file to be used in lieu of the system CA cert bundle. More...
 
virtual bool ExecuteSynchronously (std::string *response_body)=0
 Performs the HTTP request with the configured parameters and waits for the execution to complete. More...
 

Static Public Member Functions

static std::unique_ptr< HTTPTransportCreate ()
 Instantiates a concrete HTTPTransport class for the current operating system. More...
 

Protected Member Functions

const std::string & url () const
 
const std::string & method () const
 
const HTTPHeadersheaders () const
 
HTTPBodyStreambody_stream () const
 
double timeout () const
 
const base::FilePath & root_ca_certificate_path () const
 

Detailed Description

HTTPTransport executes a HTTP request using the specified URL, HTTP method, headers, and body. This class can only issue a synchronous HTTP request.

This class cannot be instantiated directly. A concrete subclass must be instantiated instead, which provides an implementation to execute the request that is appropriate for the host operating system.

Member Function Documentation

◆ Create()

std::unique_ptr< HTTPTransport > crashpad::HTTPTransport::Create ( )
static

Instantiates a concrete HTTPTransport class for the current operating system.

Returns
A new caller-owned HTTPTransport object.

◆ ExecuteSynchronously()

virtual bool crashpad::HTTPTransport::ExecuteSynchronously ( std::string *  response_body)
pure virtual

Performs the HTTP request with the configured parameters and waits for the execution to complete.

Parameters
[out]response_bodyOn success, this will be set to the HTTP response body. This parameter is optional and may be set to nullptr if the response body is not required.
Returns
Whether or not the request was successful, defined as returning a HTTP status code in the range 200-203 (inclusive).

◆ SetBodyStream()

void crashpad::HTTPTransport::SetBodyStream ( std::unique_ptr< HTTPBodyStream stream)

Sets the stream object from which to generate the HTTP body.

Parameters
[in]streamA HTTPBodyStream, of which this class will take ownership.

◆ SetHeader()

void crashpad::HTTPTransport::SetHeader ( const std::string &  header,
const std::string &  value 
)

Sets a HTTP header-value pair.

Parameters
[in]headerThe HTTP header name. Any previous value set at this name will be overwritten.
[in]valueThe value to set for the header.

◆ SetMethod()

void crashpad::HTTPTransport::SetMethod ( const std::string &  http_method)

Sets the HTTP method to execute. E.g., GET, POST, etc. The default method is "POST".

Parameters
[in]http_methodThe HTTP method.

◆ SetRootCACertificatePath()

void crashpad::HTTPTransport::SetRootCACertificatePath ( const base::FilePath &  cert)

Sets a certificate file to be used in lieu of the system CA cert bundle.

This is exposed primarily for testing with a self-signed certificate, and it isn't necessary to set it in normal use.

Parameters
[in]certThe filename of a file in PEM format containing the CA cert to be used for TLS connections.

◆ SetTimeout()

void crashpad::HTTPTransport::SetTimeout ( double  timeout)

Sets the timeout for the HTTP request. The default is 15 seconds.

Parameters
[in]timeoutThe request timeout, in seconds.

◆ SetURL()

void crashpad::HTTPTransport::SetURL ( const std::string &  url)

Sets URL to which the request will be made.

Parameters
[in]urlThe request URL.

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