List of all members
xxhr::Multipart Class Reference

Allows to specify HTTP Multipart requests. Useful in xxhr::POST context to perform data upload. More...

Detailed Description

The Multipart requests can be made of many xxhr::Part which are either buffers or file. Typically a file upload service will expect a file part in it's multipart request handling.

Uploading files requires the use Multipart, with xxhr this is really simple.

Given a web server expecting a field named somefile an xxhr::File or xxhr::Buffer can be passed as in the following example.

POST("http://httpbin.org/post"s,
Multipart{
{"somefile", File{"../../../xxhr/api.hpp"} }
},
on_response = [](auto&& resp) {
std::cout << resp.text;
std::cout << "Upload status : " << resp.error << " - " << resp.status_code << "\n";
});

Multiple files at once

It is possible, as it is a Multipart query to add many xxhr::File or xxhr::Buffer.

auto buffer = "this is some buffer"s;
POST("http://httpbin.org/post"s,
Multipart{
{"somefile", File{"../../../xxhr/api.hpp"} }
, {"other", File{"../../../xxhr/multipart.hpp"} }
, {"and_another", File{"../../../README.md"} }
, {"somebuffer", Buffer{buffer.begin(), buffer.end(), "IN_MEMORY_FILE"} }
},

The documentation for this class was generated from the following file:
xxhr::on_response
constexpr make_handler_t< on_response_ > on_response
Continuation callback ( i.e. signature : void callback(xxhr::Response)) for the asynchronous HTTP ope...
Definition: handler.hpp:39
xxhr::POST
void POST(Ts &&... ts)
HTTP POST Request.
Definition: api.hpp:47