AFLOW
 
Loading...
Searching...
No Matches
aurostd_xhttp.h
Go to the documentation of this file.
1// ***************************************************************************
2// * *
3// * Aflow STEFANO CURTAROLO - Duke University 2003-2022 *
4// * *
5// ***************************************************************************
6// Written by Frisco Rose in 2018
7// Complete rewrite by Hagen Eckert in 2022
8// hagen.eckert@duke.edu
9
10#ifndef AFLOW_SRC_AUROSTD_XHTTP_H
11#define AFLOW_SRC_AUROSTD_XHTTP_H
12
13#include <cstddef>
14#include <deque>
15#include <map>
16#include <sstream>
17#include <string>
18#include <vector>
19
20using std::deque;
21using std::string;
22using std::stringstream;
23using std::vector;
24
25namespace aurostd {
26 void httpGet(const string& url, std::string& output, long& response_code, std::map<std::string, std::string>& header);
27
28 std::string httpGet(const std::string& url);
29 std::string httpGet(const std::string& url, long& response_code);
30 std::string httpGet(const std::string& url, long& response_code, std::map<std::string, std::string>& header);
31
32 long httpGetStatus(const std::string& url);
33 long httpGetStatus(const std::string& url, std::string& output);
34 long httpGetStatus(const std::string& url, std::string& output, std::map<std::string, std::string>& header);
35
36 long httpGetStatus(const std::string& host, const std::string& path, const std::string& query, std::string& output);
37 long httpGetStatus(const std::string& host, const std::string& path, const std::string& query, std::string& output, std::map<std::string, std::string>& header);
38
39 void httpGetFile(const string& url, const string& filename, long& response_code, std::map<std::string, std::string>& header);
40
41 long httpGetFileStatus(const std::string& url, const std::string& filename);
42 long httpGetFileStatus(const std::string& url, const std::string& filename, std::map<std::string, std::string>& header);
43
44 std::string httpGetCompressedFileContent(const string& url);
45 std::string httpGetCompressedFileContent(const string& url, long& response_code);
46 std::string httpGetCompressedFileContent(const string& url, long& response_code, std::map<std::string, std::string>& header);
47
48 template <typename utype> size_t httpGetTokens(const string& url, vector<utype>& tokens, const string& delimiters = " ");
49
50 std::string httpPercentEncodingFull(std::string work_str);
51} // namespace aurostd
52
53#endif // AFLOW_SRC_AUROSTD_XHTTP_H
std::string httpGetCompressedFileContent(const string &url, long &response_code, std::map< std::string, std::string > &header)
get the content of a file from the web, decompress locally if needed
void httpGetFile(const string &url, const std::string &filename, long &response_code, std::map< std::string, std::string > &header)
get a web resource as file
size_t httpGetTokens(const string &url, vector< utype > &tokens, const string &delimiters)
get the data split into tokens
string httpPercentEncodingFull(string work_str)
Fully percent encode a string.
long httpGetStatus(const std::string &url)
Retrieve data from an url.
void httpGet(const string &url, std::string &output, long &response_code, std::map< std::string, std::string > &header)
get a web resource as string
long httpGetFileStatus(const std::string &url, const std::string &filename)
Download data as file.