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...
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< HTTPTransport > | Create ()
| 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 HTTPHeaders & | headers () const
HTTPBodyStream * | body_stream () const
double | timeout () 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_body | On 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 200 (OK) code.

## ◆ SetBodyStream()

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

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

Parameters

  [in] | stream | A 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] | header | The HTTP header name. Any previous value set at this name will be overwritten.
  [in] | value | The 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_method | The HTTP method.

## ◆ SetTimeout()

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

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

Parameters

  [in] | timeout | The request timeout, in seconds.

## ◆ SetURL()

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

Sets URL to which the request will be made.

Parameters

  [in] | url | The request URL.

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

- util/net/http_transport.h
- util/net/http_transport.cc
- util/net/http_transport_libcurl.cc
- util/net/http_transport_win.cc