cpp-ipfs-http-client
IPFS C++ client library
transport.h
1 /* Copyright (c) 2016-2019, 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 {
38  kFileName,
39  };
40 
42  const std::string path;
43 
46 
49  const std::string data;
50 };
51 
53 class Transport {
54  public:
56  virtual inline ~Transport();
57 
63  virtual void Fetch(
65  const std::string& url,
67  const std::vector<FileUpload>& files,
69  std::iostream* response) = 0;
70 
72  virtual void UrlEncode(
74  const std::string& raw,
76  std::string* encoded) = 0;
77 };
78 
80 
81 } /* namespace http */
82 } /* namespace ipfs */
83 
84 #endif /* IPFS_HTTP_TRANSPORT_H */
File whose contents is streamed to the web server.
Type type
The type of the data member.
Definition: transport.h:45
const std::string data
The data to be added.
Definition: transport.h:49
Convenience interface for talking basic HTTP.
Definition: transport.h:53
virtual void Fetch(const std::string &url, const std::vector< FileUpload > &files, std::iostream *response)=0
Fetch the contents of a given URL.
virtual ~Transport()
Destructor.
Definition: transport.h:79
IPFS namespace.
Definition: client.h:32
virtual void UrlEncode(const std::string &raw, std::string *encoded)=0
URL encode a string.
HTTP file upload.
Definition: transport.h:32
Type
The type of the data member.
Definition: transport.h:34
The file contents, put into a string by the caller.
const std::string path
File name to pretend to the web server.
Definition: transport.h:42