mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
naett has had a complete libcurl backend all along; we just never built it, so Linux ran with HTTPS_NOT_AVAILABLE. That means no homebrew store over HTTPS, and RetroAchievements talking to plain http://retroachievements.org. libcurl is loaded with dlopen rather than linked, the same way we handle the Vulkan loader, so it stays a soft dependency: we need the curl headers at build time, but a build made here still starts on a machine without libcurl installed - it just reports HTTPS as unavailable, exactly like today. Distro packagers get the behavior they'd expect either way, and certificate validation comes free from the system CA store. New net::HTTPSAvailable() answers "did that work", and SDLMain folds it into SYSPROP_SUPPORTS_HTTPS, which everything downstream already degrades on. Four fixes to the backend itself, all noted in ext/naett/README-ppsspp.md: - panic() called exit(1) on a pipe or curl_multi_perform failure. Taking the emulator down because a download failed isn't acceptable - the backend now disables itself and requests complete with naettGenericError. - CURLINFO_RESPONSE_CODE writes a long into res->code, which is an int. Eight bytes into four, getting away with it only because the next field absorbs the zeroes. - curl_easy_setopt is varargs and wants a long for these options; int literals and int variables are UB on LP64. - naettPlatformCloseResponse called through a null function pointer when libcurl was missing. Found by testing that path, which segfaulted. CI needs libcurl4-openssl-dev (curl-dev on Alpine) or it would quietly keep building without HTTPS.
naett /nɛt:/
Tiny HTTP client library in C.
Wraps native HTTP client functionality on macOS, Windows, Linux, iOS and Android in a single, simple non-blocking API.
Using naett
Get the naett.c and naett.h files and throw them into your project. Check out the example for a basic Makefile - based setup.
The library needs to be initialized by a call to naettInit(). On Android, you need to provide a JavaVM* handle in the call to naettInit().
On the other platforms, call with NULL.
See naett.h for reference docs.
Platform implementations
naett uses the following HTTP client libraries on each platform:
| Platform | Library / component | Build with |
|---|---|---|
| macOS, iOS | NSURLRequest | -framework Foundation |
| Windows | WinHTTP Sessions | -lwinhttp |
| Android | java.net.URL | NDK |
| Linux | libcurl | -lcurl -lpthread |
Example
#include "naett.h"
#include <unistd.h>
#include <stdio.h>
int main(int argc, char** argv) {
naettInit(NULL);
naettReq* req =
naettRequest("https://foo.site.net", naettMethod("GET"), naettHeader("accept", "application/json"));
naettRes* res = naettMake(req);
while (!naettComplete(res)) {
usleep(100 * 1000);
}
if (naettGetStatus(res) < 0) {
printf("Request failed\n");
return 1;
}
int bodyLength = 0;
const char* body = naettGetBody(res, &bodyLength);
printf("Got %d bytes of type '%s':\n", bodyLength, naettGetHeader(res, "Content-Type"));
printf("%.100s\n...\n", body);
}