Crashpad

Classes | Public Member Functions | List of all members
crashpad::HTTPMultipartBuilder Class Reference

This class is used to build a MIME multipart message, conforming to RFC 2046, for use as a HTTP request body. More...

`#include "util/net/http_multipart_builder.h"`

## Public Member Functions
void | SetGzipEnabled (bool gzip_enabled)
| Enables or disables `gzip` compression. More...
void | SetFormData (const std::string &key, const std::string &value)
| Sets a `Content-Disposition: form-data` key-value pair. More...
void | SetFileAttachment (const std::string &key, const std::string &upload_file_name, const base::FilePath &path, const std::string &content_type)
| Specifies the file at path to have its contents uploaded as multipart data, available at `name` of upload_file_name. More...
std::unique_ptr< HTTPBodyStream > | GetBodyStream ()
| Generates the HTTPBodyStream for the data currently supplied to the builder. More...
void | PopulateContentHeaders (HTTPHeaders *http_headers) const
| Adds the appropriate content headers to http_headers. More...

## Detailed Description

This class is used to build a MIME multipart message, conforming to RFC 2046, for use as a HTTP request body.

## Member Function Documentation

## ◆ GetBodyStream()

std::unique_ptr< HTTPBodyStream > crashpad::HTTPMultipartBuilder::GetBodyStream | ( |  | ) |

Generates the HTTPBodyStream for the data currently supplied to the builder.

Returns
  A caller-owned HTTPBodyStream object.

## ◆ PopulateContentHeaders()

void crashpad::HTTPMultipartBuilder::PopulateContentHeaders | ( | HTTPHeaders * | http_headers | ) | const

Adds the appropriate content headers to http_headers.

Any headers that this method adds will replace existing headers by the same name in http_headers.

## ◆ SetFileAttachment()

void crashpad::HTTPMultipartBuilder::SetFileAttachment | ( | const std::string & | key,
|  | const std::string & | upload_file_name,
|  | const base::FilePath & | path,
|  | const std::string & | content_type
| ) |  |

Specifies the file at path to have its contents uploaded as multipart data, available at `name` of upload_file_name.

Parameters

  [in] | key | The key of the form data, specified as the `name` in the multipart message. Any data previously set on this class with this key will be overwritten.
  [in] | upload_file_name | The `filename` to specify for this multipart data attachment.
  [in] | path | The path of the file whose contents will be uploaded.
  [in] | content_type | The `Content-Type` to specify for the attachment. If this is empty, `"application/octet-stream"` will be used.

## ◆ SetFormData()

void crashpad::HTTPMultipartBuilder::SetFormData | ( | const std::string & | key,
|  | const std::string & | value
| ) |  |

Sets a `Content-Disposition: form-data` key-value pair.

Parameters

  [in] | key | The key of the form data, specified as the `name` in the multipart message. Any data previously set on this class with this key will be overwritten.
  [in] | value | The value to set at the key.

## ◆ SetGzipEnabled()

void crashpad::HTTPMultipartBuilder::SetGzipEnabled | ( | bool | gzip_enabled | ) |

Enables or disables `gzip` compression.

Parameters

  [in] | gzip_enabled | Whether to enable or disable `gzip` compression.

When `gzip` compression is enabled, the body stream returned by GetBodyStream() will be `gzip`-compressed, and the content headers set by PopulateContentHeaders() will contain `Content-Encoding: gzip`.

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

- util/net/http_multipart_builder.h
- util/net/http_multipart_builder.cc