Go to the documentation of this file.
21 #ifdef LLVM_ENABLE_CURL
22 #include <curl/curl.h>
30 return A.Url ==
B.Url && A.Method ==
B.Method &&
31 A.FollowRedirects ==
B.FollowRedirects;
44 #ifdef LLVM_ENABLE_CURL
50 curl_global_init(CURL_GLOBAL_ALL);
57 curl_global_cleanup();
63 if (Timeout < std::chrono::milliseconds(0))
64 Timeout = std::chrono::milliseconds(0);
65 curl_easy_setopt(Curl, CURLOPT_TIMEOUT_MS, Timeout.count());
71 struct CurlHTTPRequest {
73 void storeError(
Error Err) {
80 static size_t curlWriteFunction(
char *Contents,
size_t Size,
size_t NMemb,
81 CurlHTTPRequest *CurlRequest) {
84 CurlRequest->Handler.handleBodyChunk(
StringRef(Contents, Size))) {
93 "Must call HTTPClient::initialize() at the beginning of main().");
96 Curl = curl_easy_init();
97 assert(Curl &&
"Curl could not be initialized");
99 curl_easy_setopt(Curl, CURLOPT_WRITEFUNCTION, curlWriteFunction);
108 "Unsupported CURL request method.");
111 curl_easy_setopt(Curl, CURLOPT_URL, Url.
c_str());
112 curl_easy_setopt(Curl, CURLOPT_FOLLOWLOCATION, Request.
FollowRedirects);
114 CurlHTTPRequest CurlRequest(Handler);
115 curl_easy_setopt(Curl, CURLOPT_WRITEDATA, &CurlRequest);
116 CURLcode CurlRes = curl_easy_perform(Curl);
117 if (CurlRes != CURLE_OK)
120 "curl_easy_perform() failed: %s\n",
121 curl_easy_strerror(CurlRes)));
122 return std::move(CurlRequest.ErrorState);
127 curl_easy_getinfo(Curl, CURLINFO_RESPONSE_CODE, &Code);
This is an optimization pass for GlobalISel generic memory operations.
A handler for state updates occurring while an HTTPRequest is performed.
static bool IsInitialized
static ErrorSuccess success()
Create a success value.
static void initialize()
Must be called at the beginning of a program, while it is a single thread.
HTTPRequest(StringRef Url)
static void cleanup()
Must be called at the end of a program, while it is a single thread.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Error perform(const HTTPRequest &Request, HTTPResponseHandler &Handler)
Performs the Request, passing response data to the Handler.
unsigned responseCode()
Returns the last received response code or zero if none.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Error joinErrors(Error E1, Error E2)
Concatenate errors.
static bool isAvailable()
Returns true only if LLVM has been compiled with a working HTTPClient.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void setTimeout(std::chrono::milliseconds Timeout)
Sets the timeout for the entire request, in milliseconds.
bool operator==(uint64_t V1, const APInt &V2)
static const HTTPClientCleanup Cleanup
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
A stateless description of an outbound HTTP request.
Lightweight error class with error context and mandatory checking.
StringRef str() const
Explicit conversion to StringRef.