Skip to content

fastc-lang/fastc-core-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastc-core-http

HTTP/1.1 client preview for fastC.

Part of the fastc-core launch set. Implementation ships in the fastC v1.0 prelude — use http::* works out of the box.

Cap-typed surface

use http::get_status;
// (c: ref(CapNetConnect), host: raw(u8), port: i32, path: raw(u8)) -> i32

get_status opens a TCP connection, sends an HTTP/1.1 GET, parses the response status code, and closes. Returns the 3-digit status (200/404/etc.) or -1 on any error.

The capability wedge

Every fastC function that reaches the network must declare c: ref(CapNetConnect). A function without that parameter structurally cannot call http::get_status — the type system makes it impossible. The cap can only be minted in main via caps::init(); library code never fabricates it. The fabrication check is enforced by the compiler (see fastC's cap_check pass).

Example

use http::get_status;
use caps::init;
use io::println;
use io::print_int;
use io::put_char;

fn main() -> i32 {
    let bundle: Caps = init();
    let status: i32 = get_status(
        addr(bundle.net_connect),
        cstr("127.0.0.1"),
        8088,
        cstr("/"),
    );
    println(cstr("status:"));
    print_int(status);
    put_char(10);
    return status;
}

v1 scope

Capability Status
GET request
Status line parsing
Capability-typed I/O via CapNetConnect
Body delivery to caller follow-up
Header inspection follow-up
POST / other methods follow-up
HTTP/2 follow-up
TLS needs fastc-core-tls (deferred)
Chunked transfer encoding follow-up
Redirect following follow-up

WASI

The fastC runtime ships link-compatible stubs for wasm32-wasi that return -1. Full BSD-socket support follows the wasi:sockets Preview 2 stabilization.

Status

v0.1.0 — preview. API is final.

License

MIT

About

HTTP/1.1 client preview (CapNetConnect-gated) for fastC. Part of the fastc-core launch set.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors