I'm using curl-7.64.1 (https://curl.haxx.se/windows/) 32 bit, with OpenSSL 1.1.1b (32 bit) and tidy-5.0.0 for XML parsing.
When I'm home making any connection work fine, but when I'm at School, connected to the Wifi of this one. All the connection are refused.
I tried to make a connection to https://www.google.fr/ and with CURLOPT_VERBOSE I get on the screen the message :
- Trying 172.217.18.227...
- TCP_NODELAY set
- connect to 172.217.18.227 port 443 failed: Connection refused
- Failed to connect to www.google.fr port 443: Connection refused
- Closing connection 0 Failed to connect to www.google.fr port 443: Connection refused
I tried first to change the port, to 8080. I wrote https://www.google.fr:8080 as URL for libCurl. But still have : Failed to connect to www.google.fr port 8080: Connection refused
After I tried to setup a proxy in the LibCurl connection. But it didn't change anything.
CURL *curl;
char curl_errbuf[CURL_ERROR_SIZE];
TidyDoc tdoc;
TidyBuffer docbuf = {0};
TidyBuffer tidy_errbuf = {0};
int err;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.fr:8080");
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errbuf);
//curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
tdoc = tidyCreate();
tidyOptSetBool(tdoc, TidyForceOutput, yes);
tidyOptSetInt(tdoc, TidyWrapLen, 4096);
tidySetErrorBuffer(tdoc, &tidy_errbuf);
tidyBufInit(&docbuf);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &docbuf);
curl_easy_setopt(curl, CURLOPT_PROXY, "http://212.129.52.155:8080");
err = curl_easy_perform(curl);
I would like make the connection work on the Wifi of my School.
EDIT 1 :
Following the advise in this post : Can servers block curl requests?
I exacted the headers from Chrome and added it into LibCurl.
struct curl_slist *list = NULL;
list = curl_slist_append(list, "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
list = curl_slist_append(list, "accept-encoding: gzip, deflate, br");
list = curl_slist_append(list, "accept-language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7");
list = curl_slist_append(list, "cache-control: max-age=0");
list = curl_slist_append(list, "upgrade-insecure-requests: 1");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
I enable the UserAgent settings :
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36");
And I added cookies :
curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1L);
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookies.txt");
But after all the connection still failed.