Add base64 encode and decode.

This commit is contained in:
Chunting Gu
2019-03-27 14:06:22 +08:00
parent ee56fe9d1b
commit 18db152419
7 changed files with 249 additions and 23 deletions
+16
View File
@@ -1,4 +1,5 @@
#include <iostream>
#include <fstream>
#include "webcc/http_client_session.h"
#include "webcc/logger.h"
@@ -89,6 +90,21 @@ void ExampleCompression() {
std::cout << r->content() << std::endl;
}
// Get an image from HttpBin.org and save to the given file path.
// E.g., ExampleImage("E:\\example.jpeg")
void ExampleImage(const std::string& path) {
HttpClientSession session;
auto r = session.Get("http://httpbin.org/image/jpeg");
// Or
// auto r = session.Get("http://httpbin.org/image", {},
// {"Accept", "image/jpeg"});
std::ofstream ofs(path, std::ios::binary);
ofs << r->content();
}
int main() {
WEBCC_LOG_INIT("", LOG_CONSOLE);