API Reference › Http
namespace

Http

A poll-based HTTP / HTTPS client for out-of-band data — leaderboards, cloud saves, remote config, telemetry, downloads. Open a request with Http.get / Http.post (or Http.open to add headers first), then each frame call Http.poll — it returns -1 while pending, 0 on error, or the status code — so the frame never blocks. Read the reply with Http.status / ok / text / header, and pair it with Json.* for (de)serialization. TLS is the system's, on by default. A large download goes to a file instead of memory with Http.save_to, and Http.received / expected drive a progress bar while it is pending. HTTP depends on the network and the wall clock, so — like Net.* and Time.now — it is out-of-band and must never feed the deterministic lockstep/replay simulation. The transport is NSURLConnection / NSURLSession on macOS and WinHTTP on Windows; the raw-response parser (Http.parse) is pure and portable.

Http.get(url) -> intStart an async GET request.Http.post(url, body) -> intStart an async POST with a body.Http.request(method, url, body) -> intStart a request with any method.Http.open(method, url) -> intOpen a request to configure before sending.Http.set(handle, name, value) -> voidSet a request header before sending.Http.body(handle, body) -> voidSet a string request body.Http.body_bytes(handle, bytes, len) -> voidSet a raw byte request body.Http.send(handle) -> voidDispatch an opened request.Http.poll(handle) -> intPoll a request; -1 pending, 0 error, else status.Http.status(handle) -> intThe response HTTP status code.Http.ok(handle) -> boolWas the response status 2xx?Http.text(handle) -> strThe response body as text.Http.body_len(handle) -> intThe response body length in bytes.Http.header(handle, name) -> strA response header value (case-insensitive).Http.free(handle) -> voidRelease a request's resources.Http.parse(bytes, len) -> intParse a raw HTTP response into a handle.Http.save_to(handle, path) -> voidStream the response body to a file.Http.received(handle) -> intBody bytes received so far.Http.expected(handle) -> intThe body length the server announced, or -1.
← All symbols