cpp-ipfs-http-client: /media/melroy/Data/Projects/cpp-ipfs-http-client/include/ipfs/http/transport.h Source File

cpp-ipfs-http-client IPFS C++ client library

transport.h
1 /* Copyright (c) 2016-2021, The C++ IPFS client library developers
2
3 Permission is hereby granted, free of charge, to any person obtaining a copy of
4 this software and associated documentation files (the "Software"), to deal in
5 the Software without restriction, including without limitation the rights to
6 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7 the Software, and to permit persons to whom the Software is furnished to do so,
8 subject to the following conditions:
9
10 The above copyright notice and this permission notice shall be included in all
11 copies or substantial portions of the Software.
12
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
19
20 #ifndef IPFS_HTTP_TRANSPORT_H
21 #define IPFS_HTTP_TRANSPORT_H
22
23 #include <iostream>
24 #include <string>
25 #include <vector>
26
27 namespace ipfs {
28
29 namespace http {
30
32 struct FileUpload {
34 enum class Type {
36 kFileContents,
38 kFileName,
39 };
40
42 const std::string path;
43
45 Type type;
46
49 const std::string data;
50 };
51
53 class Transport {
54 public:
56 virtual inline ~Transport();
57
64 virtual void Fetch(
66 const std::string& url,
68 const std::vector<FileUpload>& files,
70 std::iostream* response) = 0;
71
75 virtual void UrlEncode(
77 const std::string& raw,
79 std::string* encoded) = 0;
80 };
81
82 inline Transport::~Transport() {}
83
84 } /* namespace http */
85 } /* namespace ipfs */
86
87 #endif /* IPFS_HTTP_TRANSPORT_H */
ipfs::http::FileUpload::data
const std::string data
The data to be added.
Definition: transport.h:49
ipfs::http::Transport::UrlEncode
virtual void UrlEncode(const std::string &raw, std::string *encoded)=0
URL encode a string.
ipfs::http::FileUpload::Type::kFileName
@ kFileName
File whose contents is streamed to the web server.
ipfs::http::Transport::~Transport
virtual ~Transport()
Destructor.
Definition: transport.h:82
ipfs::http::FileUpload::path
const std::string path
File name to pretend to the web server.
Definition: transport.h:42
ipfs::http::FileUpload::Type
Type
The type of the data member.
Definition: transport.h:34
ipfs::http::Transport::Fetch
virtual void Fetch(const std::string &url, const std::vector< FileUpload > &files, std::iostream *response)=0
Fetch the contents of a given URL.
ipfs::http::FileUpload::type
Type type
The type of the data member.
Definition: transport.h:45
ipfs::http::Transport
Convenience interface for talking basic HTTP.
Definition: transport.h:53
ipfs::http::FileUpload::Type::kFileContents
@ kFileContents
The file contents, put into a string by the caller.
ipfs
IPFS namespace.
Definition: client.h:32
ipfs::http::FileUpload
HTTP file upload.
Definition: transport.h:32