24 lines
No EOL
5.9 KiB
HTML
24 lines
No EOL
5.9 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Http — Ludic</title>
|
||
<meta name="description" content="A poll-based HTTP / HTTPS client for out-of-band data — leaderboards, cloud saves, remote config, telemetry, downloads.">
|
||
<link rel="stylesheet" href="base.css">
|
||
<link rel="stylesheet" href="docs.css">
|
||
</head>
|
||
<body>
|
||
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||
<main class="wrap item">
|
||
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <span class="here">Http</span></div>
|
||
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Http</h1></div>
|
||
<p class="ns-blurb">A poll-based HTTP / HTTPS client for out-of-band data — leaderboards, cloud saves, remote config, telemetry, downloads. Open a request with <a href="http-get.html"><code>Http.get</code></a> / <a href="http-post.html"><code>Http.post</code></a> (or <a href="http-open.html"><code>Http.open</code></a> to add headers first), then each frame call <a href="http-poll.html"><code>Http.poll</code></a> — it returns <code>-1</code> while pending, <code>0</code> on error, or the status code — so the frame never blocks. Read the reply with <a href="http-status.html"><code>Http.status</code></a> / <a href="http-ok.html"><code>ok</code></a> / <a href="http-text.html"><code>text</code></a> / <a href="http-header.html"><code>header</code></a>, and pair it with <code>Json.*</code> for (de)serialization. TLS is the system's, on by default. A large download goes to a file instead of memory with <a href="http-save_to.html"><code>Http.save_to</code></a>, and <a href="http-received.html"><code>Http.received</code></a> / <a href="http-expected.html"><code>expected</code></a> drive a progress bar while it is pending.
|
||
|
||
HTTP depends on the network and the wall clock, so — like <code>Net.*</code> and <code>Time.now</code> — it is <strong>out-of-band</strong> and must never feed the deterministic lockstep/replay simulation. The transport is NSURLConnection / NSURLSession on macOS and WinHTTP on Windows; the raw-response parser (<a href="http-parse.html"><code>Http.parse</code></a>) is pure and portable.</p>
|
||
<div class="ns-methods"><a class="ns-method" href="http-get.html"><code class="nm-sig">Http.get(url) -> int</code><span class="nm-tip">Start an async GET request.</span></a><a class="ns-method" href="http-post.html"><code class="nm-sig">Http.post(url, body) -> int</code><span class="nm-tip">Start an async POST with a body.</span></a><a class="ns-method" href="http-request.html"><code class="nm-sig">Http.request(method, url, body) -> int</code><span class="nm-tip">Start a request with any method.</span></a><a class="ns-method" href="http-open.html"><code class="nm-sig">Http.open(method, url) -> int</code><span class="nm-tip">Open a request to configure before sending.</span></a><a class="ns-method" href="http-set.html"><code class="nm-sig">Http.set(handle, name, value) -> void</code><span class="nm-tip">Set a request header before sending.</span></a><a class="ns-method" href="http-body.html"><code class="nm-sig">Http.body(handle, body) -> void</code><span class="nm-tip">Set a string request body.</span></a><a class="ns-method" href="http-body_bytes.html"><code class="nm-sig">Http.body_bytes(handle, bytes, len) -> void</code><span class="nm-tip">Set a raw byte request body.</span></a><a class="ns-method" href="http-send.html"><code class="nm-sig">Http.send(handle) -> void</code><span class="nm-tip">Dispatch an opened request.</span></a><a class="ns-method" href="http-poll.html"><code class="nm-sig">Http.poll(handle) -> int</code><span class="nm-tip">Poll a request; -1 pending, 0 error, else status.</span></a><a class="ns-method" href="http-status.html"><code class="nm-sig">Http.status(handle) -> int</code><span class="nm-tip">The response HTTP status code.</span></a><a class="ns-method" href="http-ok.html"><code class="nm-sig">Http.ok(handle) -> bool</code><span class="nm-tip">Was the response status 2xx?</span></a><a class="ns-method" href="http-text.html"><code class="nm-sig">Http.text(handle) -> str</code><span class="nm-tip">The response body as text.</span></a><a class="ns-method" href="http-body_len.html"><code class="nm-sig">Http.body_len(handle) -> int</code><span class="nm-tip">The response body length in bytes.</span></a><a class="ns-method" href="http-header.html"><code class="nm-sig">Http.header(handle, name) -> str</code><span class="nm-tip">A response header value (case-insensitive).</span></a><a class="ns-method" href="http-free.html"><code class="nm-sig">Http.free(handle) -> void</code><span class="nm-tip">Release a request's resources.</span></a><a class="ns-method" href="http-parse.html"><code class="nm-sig">Http.parse(bytes, len) -> int</code><span class="nm-tip">Parse a raw HTTP response into a handle.</span></a><a class="ns-method" href="http-save_to.html"><code class="nm-sig">Http.save_to(handle, path) -> void</code><span class="nm-tip">Stream the response body to a file.</span></a><a class="ns-method" href="http-received.html"><code class="nm-sig">Http.received(handle) -> int</code><span class="nm-tip">Body bytes received so far.</span></a><a class="ns-method" href="http-expected.html"><code class="nm-sig">Http.expected(handle) -> int</code><span class="nm-tip">The body length the server announced, or -1.</span></a></div>
|
||
<a class="back" href="api.html">← All symbols</a>
|
||
</main>
|
||
<script src="ludic-highlight.js"></script>
|
||
<script>Ludic.installCards(); Ludic.flashTarget();</script>
|
||
</body></html> |