File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- {
2- "name" : " @github/copilot-xcode " ,
3- "version" : " 0.0.1 " ,
4- "description" : " Package for downloading @github/copilot-language-server " ,
5- "private" : true ,
6- "dependencies" : {
7- "@github/copilot-language-server" : " ^1.277.0 "
8- }
1+ g++ -o curl_example curl_example.cpp -lcurl
2+ #include <iostream>
3+ #include <string>
4+ #include <curl/curl.h>
5+
6+ static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) {
7+ ((std::string*)userp)->append((char*)contents, size * nmemb);
8+ return size * nmemb;
99}
10+
11+ int main() {
12+ CURL *curl;
13+ CURLcode res;
14+ std::string readBuffer;
15+
16+ curl_global_init(CURL_GLOBAL_DEFAULT);
17+ curl = curl_easy_init();
18+ if(curl) {
19+ curl_easy_setopt(curl, CURLOPT_URL, "https:
20+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
21+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
22+ res = curl_easy_perform(curl);
23+ if(res != CURLE_OK) {
24+ std::cerr << "cURL error: " << curl_easy_strerror(res) << std::endl;
25+ } else {
26+ std::cout << readBuffer << std::endl;
27+ }
28+ curl_easy_cleanup(curl);
29+ }
30+ curl_global_cleanup();
31+ return 0;
32+ }
33+ ./curl_example
You can’t perform that action at this time.
0 commit comments