68 lines
1.9 KiB
C
68 lines
1.9 KiB
C
/*
|
|
* HTTP Test - Verify curl works with OpenSSL migration
|
|
* Simple test to fetch https://google.com using curl
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <curl/curl.h>
|
|
|
|
// Callback to write received data
|
|
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, char *userp) {
|
|
size_t realsize = size * nmemb;
|
|
printf("%.*s", (int)realsize, (char*)contents);
|
|
return realsize;
|
|
}
|
|
|
|
int main() {
|
|
printf("HTTP Test - Testing curl with HTTPS\n");
|
|
printf("===================================\n");
|
|
|
|
CURL *curl;
|
|
CURLcode res;
|
|
|
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
|
curl = curl_easy_init();
|
|
|
|
if(curl) {
|
|
// Set URL
|
|
curl_easy_setopt(curl, CURLOPT_URL, "https://google.com");
|
|
|
|
// Set callback for received data
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
|
|
|
// Follow redirects
|
|
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
|
|
|
// Set timeout
|
|
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30L);
|
|
|
|
// Perform the request
|
|
printf("Fetching https://google.com...\n");
|
|
res = curl_easy_perform(curl);
|
|
|
|
// Check for errors
|
|
if(res != CURLE_OK) {
|
|
printf("❌ curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
|
|
curl_easy_cleanup(curl);
|
|
curl_global_cleanup();
|
|
return 1;
|
|
} else {
|
|
printf("✅ HTTPS request successful!\n");
|
|
printf("✅ curl + OpenSSL compatibility verified\n");
|
|
}
|
|
|
|
// Cleanup
|
|
curl_easy_cleanup(curl);
|
|
} else {
|
|
printf("❌ Failed to initialize curl\n");
|
|
curl_global_cleanup();
|
|
return 1;
|
|
}
|
|
|
|
curl_global_cleanup();
|
|
printf("\n🎉 HTTP Test PASSED - No SSL conflicts detected\n");
|
|
return 0;
|
|
}
|