Add base64 encode and decode.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user