Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Http.hpp « Utils « slic3r « src « xs - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6ac5fcce10ccbd5bc77c073e0eddf14b6a11db7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef slic3r_Http_hpp_
#define slic3r_Http_hpp_

#include <memory>
#include <string>
#include <functional>


namespace Slic3r {


/// Represetns a Http request
class Http : public std::enable_shared_from_this<Http> {
private:
	struct priv;
public:
	typedef std::shared_ptr<Http> Ptr;
	typedef std::function<void(std::string /* body */, unsigned /* http_status */)> CompleteFn;
	typedef std::function<void(std::string /* body */, std::string /* error */, unsigned /* http_status */)> ErrorFn;

	Http(Http &&other);

	static Http get(std::string url);
	static Http post(std::string url);
	~Http();

	Http(const Http &) = delete;
	Http& operator=(const Http &) = delete;
	Http& operator=(Http &&) = delete;

	Http& size_limit(size_t sizeLimit);
	Http& header(std::string name, const std::string &value);
	Http& remove_header(std::string name);
	Http& ca_file(const std::string &filename);
	Http& form_add(const std::string &name, const std::string &contents);
	Http& form_add_file(const std::string &name, const std::string &filename);

	Http& on_complete(CompleteFn fn);
	Http& on_error(ErrorFn fn);

	Ptr perform();
	void perform_sync();

	static bool ca_file_supported();
private:
	Http(const std::string &url);

	std::unique_ptr<priv> p;
};


}

#endif