diff options
author | Daniel Wilhelm <shieldwed@outlook.com> | 2018-06-30 12:43:08 +0200 |
---|---|---|
committer | Daniel Wilhelm <shieldwed@outlook.com> | 2018-06-30 12:43:08 +0200 |
commit | a98326eb2954ac1e79f5eac28dbeab3ec15e047f (patch) | |
tree | bb16257a1894b488e365851273735ec13a9442ef /zen/http.h | |
parent | 10.0 (diff) | |
download | FreeFileSync-a98326eb2954ac1e79f5eac28dbeab3ec15e047f.tar.gz FreeFileSync-a98326eb2954ac1e79f5eac28dbeab3ec15e047f.tar.bz2 FreeFileSync-a98326eb2954ac1e79f5eac28dbeab3ec15e047f.zip |
10.1
Diffstat (limited to 'zen/http.h')
-rwxr-xr-x | zen/http.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/zen/http.h b/zen/http.h new file mode 100755 index 00000000..5d84be2c --- /dev/null +++ b/zen/http.h @@ -0,0 +1,48 @@ +// ***************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0 * +// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved * +// ***************************************************************************** + +#ifndef HTTP_H_879083425703425702 +#define HTTP_H_879083425703425702 + +#include <zen/zstring.h> +#include <zen/sys_error.h> +#include <zen/serialize.h> + +namespace zen +{ +/* + - thread-safe! (Window/Linux/macOS) + - HTTPS supported only for Windows +*/ +class HttpInputStream +{ +public: + //support zen/serialize.h buffered input stream concept + size_t read(void* buffer, size_t bytesToRead); //throw SysError, X; return "bytesToRead" bytes unless end of stream! + std::string readAll(); //throw SysError, X + + size_t getBlockSize() const; + + class Impl; + HttpInputStream(std::unique_ptr<Impl>&& pimpl); + HttpInputStream(HttpInputStream&&) noexcept = default; + ~HttpInputStream(); + +private: + std::unique_ptr<Impl> pimpl_; +}; + + +HttpInputStream sendHttpGet (const Zstring& url, const Zstring& userAgent, const IOCallback& notifyUnbufferedIO /*throw X*/); //throw SysError +HttpInputStream sendHttpPost(const Zstring& url, const Zstring& userAgent, const IOCallback& notifyUnbufferedIO /*throw X*/, // + const std::vector<std::pair<std::string, std::string>>& postParams); +bool internetIsAlive(); //noexcept + +std::string xWwwFormUrlEncode(const std::vector<std::pair<std::string, std::string>>& paramPairs); +std::vector<std::pair<std::string, std::string>> xWwwFormUrlDecode(const std::string& str); +} + +#endif //HTTP_H_879083425703425702 |