~/bend-docscommunity

src/h2io.bend relies on unsafe/foreign

raw source on the hub · import bend-kube-runtime@0.10.0.0/src/h2io.bend as H2io

4 imports
import Base
import ./http.bend as H
import ./h2.bend as T
import ./sys.bend as Y

Types

type SEv source · line 29 · raw

Data

type H2Msg source · line 34 · raw

Data

type H2Req source · line 44 · raw

Data

A stream a client opened on a server: its id, its events (the request's headers first), and the connection to answer on.

type Route source · line 47 · raw

Data

type REv source · line 57 · raw

Type

type WEv source · line 90 · raw

Type

type Applied source · line 137 · raw

Data

type MEv source · line 308 · raw

Type

type AEv source · line 366 · raw

Type

type H2Resp source · line 410 · raw

Data

A whole response: its headers, body and trailers.

type CEv source · line 432 · raw

Type

Definitions

def H2io.fuel source · line 51 · raw

Nat

Each loop runs on two counters of fuel: 2^64 turns.

def REv.of source · line 60 · raw

@p:Pair(Socket, Result<&1, &1, Pair(U32, String), Maybe<&1, List<&2, U32>>>) -> REv

def H2io.reader source · line 65 · raw

@outer:Nat -> @fuel:Nat -> @ev:REv -> @+inbox:Chan(H2Msg) -> IO(Unit)

def H2io.read source · line 82 · raw

@s:Socket -> @+inbox:Chan(H2Msg) -> IO(Unit)

Reads s until it ends, passing each read to inbox, then MEof.

def WEv.sent source · line 94 · raw

@p:Pair(Socket, Result<&1, &1, Pair(Pair(U32, String), List<&2, U32>), Unit>) -> WEv

def H2io.hang_up source · line 99 · raw

@s:Socket -> IO(Unit)

def H2io.writer source · line 104 · raw

@outer:Nat -> @fuel:Nat -> @ev:WEv -> @+wr:Chan(List<&2, U32>) -> IO(Unit)

def H2io.write source · line 129 · raw

@s:Socket -> @+wr:Chan(List<&2, U32>) -> IO(Unit)

Writes what wr carries to s, until wr closes; then hangs up.

def H2io.route.pick source · line 140 · raw

@+ch:Chan(SEv) -> @rest:Maybe<&2, Chan(SEv)> -> @hit:Bool -> Maybe<&2, Chan(SEv)>

def H2io.route source · line 147 · raw

@rs:List<&2, Route> -> @+sid:U32 -> Maybe<&2, Chan(SEv)>

def H2io.unroute.pick source · line 154 · raw

@r:Route -> @rest:List<&2, Route> -> @hit:Bool -> List<&2, Route>

def H2io.unroute source · line 161 · raw

@rs:List<&2, Route> -> @+sid:U32 -> List<&2, Route>

def H2io.tell source · line 168 · raw

@+ch:Chan(SEv) -> @e:SEv -> IO(Unit)

def H2io.tell_all source · line 173 · raw

@rs:List<&2, Route> -> @+e:SEv -> IO(Unit)

def H2io.keep source · line 182 · raw

@rs:List<&2, Route> -> @+sid:U32 -> @done:Bool -> List<&2, Route>

def H2io.accept source · line 190 · raw

@q:Maybe<&2, Chan(H2Req)> -> @+sid:U32 -> @e:SEv -> @done:Bool -> @rs:List<&2, Route> -> @+inbox:Chan(H2Msg) -> IO(List<&2, Route>)

A new stream from the peer: its channel, handed to the application.

def H2io.to source · line 202 · raw

@m:Maybe<&2, Chan(SEv)> -> @+sid:U32 -> @e:SEv -> @+done:Bool -> @rs:List<&2, Route> -> @+inbox:Chan(H2Msg) -> @q:Maybe<&2, Chan(H2Req)> -> @fresh:Bool -> IO(List<&2, Route>)

def H2io.deliver1 source · line 216 · raw

@e:0xc8d18670ba37041507e7f53cc7972ec6/src/h2.H2Ev -> @+rs:List<&2, Route> -> @+inbox:Chan(H2Msg) -> @q:Maybe<&2, Chan(H2Req)> -> IO(List<&2, Route>)

One event of the connection, to its stream's channel; a server's new stream goes to the application first.

def H2io.deliver source · line 234 · raw

@evs:List<&2, 0xc8d18670ba37041507e7f53cc7972ec6/src/h2.H2Ev> -> @rs:List<&2, Route> -> @+inbox:Chan(H2Msg) -> @+q:Maybe<&2, Chan(H2Req)> -> IO(List<&2, Route>)

def H2io.send_out source · line 242 · raw

@bs:List<&2, U32> -> @+wr:Chan(List<&2, U32>) -> @empty:Bool -> IO(Unit)

def H2io.start_close source · line 251 · raw

@+wr:Chan(List<&2, U32>) -> @now:Bool -> IO(Unit)

def H2io.flush.go source · line 261 · raw

@t:0xc8d18670ba37041507e7f53cc7972ec6/src/h2.H2Take -> @rs:List<&2, Route> -> @+cl:Bool -> @+wr:Chan(List<&2, U32>) -> @+inbox:Chan(H2Msg) -> @+q:Maybe<&2, Chan(H2Req)> -> IO(Applied)

After a message: the bytes to the writer, the events to their streams, and, once the connection is over, the writer closed (it hangs up after the last bytes, which ends the reader, whose MEof ends the manager).

def H2io.flush source · line 271 · raw

@a:Applied -> @+wr:Chan(List<&2, U32>) -> @+inbox:Chan(H2Msg) -> @+q:Maybe<&2, Chan(H2Req)> -> IO(Applied)

def H2io.opened.go source · line 276 · raw

@c:0xc8d18670ba37041507e7f53cc7972ec6/src/h2.H2 -> @+sid:U32 -> @rs:List<&2, Route> -> @cl:Bool -> @+back:Chan(SEv) -> @none:Bool -> IO(Applied)

def H2io.opened source · line 287 · raw

@o:0xc8d18670ba37041507e7f53cc7972ec6/src/h2.H2Opened -> @rs:List<&2, Route> -> @cl:Bool -> @+back:Chan(SEv) -> IO(Applied)

def H2io.apply source · line 293 · raw

@c:0xc8d18670ba37041507e7f53cc7972ec6/src/h2.H2 -> @rs:List<&2, Route> -> @cl:Bool -> @m:H2Msg -> IO(Applied)

One message to the connection.

def MEv.of source · line 311 · raw

@a:Applied -> @m:Maybe<&1, H2Msg> -> MEv

def H2io.end source · line 315 · raw

@rs:List<&2, Route> -> @+wr:Chan(List<&2, U32>) -> @+inbox:Chan(H2Msg) -> @cl:Bool -> IO(Unit)

The connection ended: every stream hears it, and the channels close.

def H2io.mgr source · line 321 · raw

@outer:Nat -> @fuel:Nat -> @ev:MEv -> @+inbox:Chan(H2Msg) -> @+wr:Chan(List<&2, U32>) -> @+q:Maybe<&2, Chan(H2Req)> -> IO(Unit)

def H2io.split source · line 339 · raw

@p:Pair(Socket, Result<&1, &1, Pair(U32, String), Socket>) -> @cfg:0xc8d18670ba37041507e7f53cc7972ec6/src/h2.H2Cfg -> @+q:Maybe<&2, Chan(H2Req)> -> @+inbox:Chan(H2Msg) -> @+wr:Chan(List<&2, U32>) -> IO(Unit)

def H2io.conn source · line 355 · raw

@s:Socket -> @cfg:0xc8d18670ba37041507e7f53cc7972ec6/src/h2.H2Cfg -> @+q:Maybe<&2, Chan(H2Req)> -> IO(Chan(H2Msg))

Runs an HTTP/2 connection on s with our settings cfg; a server's new streams go to q. Answers the connection's inbox at once.

def AEv.of source · line 369 · raw

@p:Pair(Listener, Result<&1, &1, Pair(U32, String), Socket>) -> AEv

def H2io.serve1 source · line 374 · raw

@r:Result<&1, &1, Pair(U32, String), Socket> -> @+reqs:Chan(H2Req) -> IO(Unit)

def H2io.accepting source · line 383 · raw

@outer:Nat -> @fuel:Nat -> @ev:AEv -> @+reqs:Chan(H2Req) -> IO(Unit)

def H2io.serve source · line 397 · raw

@l:Listener -> @+reqs:Chan(H2Req) -> IO(Unit)

Serves HTTP/2 on l (TCP.listen, Y.Sys.listen or Y.Sys.unix_listen), each stream a client opens going to reqs.

def H2io.client source · line 403 · raw

@s:Socket -> IO(Chan(H2Msg))

A client connection on s (TCP.connect or Y.Sys.unix_connect).

def H2io.got_headers source · line 413 · raw

@r:H2Resp -> @hs:List<&2, 0xc8d18670ba37041507e7f53cc7972ec6/src/http.Header> -> H2Resp

def H2io.got_data source · line 422 · raw

@r:H2Resp -> @bs:List<&2, U32> -> H2Resp

While a response is collected, its body is kept reversed, so each DATA frame costs its own length; H2io.fin turns it round.

def H2io.fin source · line 427 · raw

@r:H2Resp -> H2Resp

def H2io.collect source · line 435 · raw

@outer:Nat -> @fuel:Nat -> @ev:CEv -> @+back:Chan(SEv) -> IO(Result<&2, &2, String, H2Resp>)

def H2io.call.opened source · line 464 · raw

@m:Maybe<&1, SEv> -> @+conn:Chan(H2Msg) -> @+back:Chan(SEv) -> @body:List<&2, U32> -> IO(Result<&2, &2, String, H2Resp>)

def H2io.call source · line 479 · raw

@+conn:Chan(H2Msg) -> @hs:List<&2, 0xc8d18670ba37041507e7f53cc7972ec6/src/http.Header> -> @body:List<&2, U32> -> IO(Result<&2, &2, String, H2Resp>)

A request with headers hs and body on conn (H2io.client's), and its whole response.