cpp-ipfs-http-client
IPFS C++ client library
Loading...
Searching...
No Matches
transport.h
1/* Copyright (c) 2016-2023, The C++ IPFS client library developers
2
3Permission is hereby granted, free of charge, to any person obtaining a copy of
4this software and associated documentation files (the "Software"), to deal in
5the Software without restriction, including without limitation the rights to
6use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7the Software, and to permit persons to whom the Software is furnished to do so,
8subject to the following conditions:
9
10The above copyright notice and this permission notice shall be included in all
11copies or substantial portions of the Software.
12
13THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18CONNECTION 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 <memory>
25#include <string>
26#include <vector>
27
28namespace ipfs {
29
30namespace http {
31
33struct FileUpload {
35 enum class Type {
40 };
41
43 const std::string path;
44
47
50 const std::string data;
51};
52
54class Transport {
55 public:
60 virtual std::unique_ptr<Transport> Clone() const = 0;
61
63 virtual inline ~Transport();
64
72 virtual void Fetch(
74 const std::string& url,
76 const std::vector<FileUpload>& files,
78 std::iostream* response) = 0;
79
87 virtual void StopFetch() = 0;
88
96 virtual void ResetFetch() = 0;
97
101 virtual void UrlEncode(
103 const std::string& raw,
105 std::string* encoded) = 0;
106};
107
109
110} /* namespace http */
111} /* namespace ipfs */
112
113#endif /* IPFS_HTTP_TRANSPORT_H */
Convenience interface for talking basic HTTP.
Definition transport.h:54
virtual void Fetch(const std::string &url, const std::vector< FileUpload > &files, std::iostream *response)=0
Fetch the contents of a given URL.
virtual void ResetFetch()=0
Reset the internal state, after StopFetch() is called.
virtual ~Transport()
Destructor.
Definition transport.h:108
virtual void StopFetch()=0
Stop the Fetch method abruptly.
virtual std::unique_ptr< Transport > Clone() const =0
Return a deep copy of this object.
virtual void UrlEncode(const std::string &raw, std::string *encoded)=0
URL encode a string.
IPFS namespace.
Definition client.h:33
HTTP file upload.
Definition transport.h:33
Type
The type of the data member.
Definition transport.h:35
@ kFileName
File whose contents is streamed to the web server.
@ kFileContents
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:43
const std::string data
The data to be added.
Definition transport.h:50
Type type
The type of the data member.
Definition transport.h:46