userver: userver/clients/http/form.hpp Source File
Loading...
Searching...
No Matches
form.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/clients/http/form.hpp
4/// @brief @copybrief clients::http::Form
5
6#include <memory>
7#include <string>
8
9#include <userver/utils/zstring_view.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace curl {
14class form;
15} // namespace curl
16
17namespace clients::http {
18
19/// @brief Multipart HTTP form builder
20class Form final {
21public:
22 Form();
23 ~Form();
24
25 Form(const Form&) = delete;
26 Form(Form&&) noexcept;
27 Form& operator=(const Form&) = delete;
28 Form& operator=(Form&&) noexcept;
29
30 void AddContent(std::string_view key, std::string_view content);
31 void AddContent(std::string_view key, std::string_view content, utils::zstring_view content_type);
32
33 void AddBuffer(std::string_view key, utils::zstring_view file_name, const std::shared_ptr<std::string>& buffer);
34 void AddBuffer(
35 std::string_view key,
36 utils::zstring_view file_name,
37 const std::shared_ptr<std::string>& buffer,
38 utils::zstring_view content_type
39 );
40
41 /// @cond
42 // Call of this method will invalidate the form
43 std::unique_ptr<curl::form> GetNative() &&;
44 /// @endcond
45
46private:
47 std::unique_ptr<curl::form> impl_;
48};
49
50} // namespace clients::http
51
52USERVER_NAMESPACE_END