~/bend-docscommunity

client.bend relies on unsafe/foreign

raw source on the hub · import 0x5e4e2a9db839a0214ace6923b04b685b/client.bend as Client

ezhttp/client: fetch a URL. URL and HTTP parsing joined to the wire effect. Answers a structured Response (status + headers + body), not a hub-style "0\n…" string contract.

6 imports
import Base
import ./url.bend as Url
import ./http.bend as Http
import ./body.bend as Body
import ./wire.bend as Wire
import ./b64.bend as B64

Types

type Response source · line 12 · raw

Data

structured client result: transport/parse error, or an HTTP response

Definitions

def wire.code source · line 17 · raw

@raw:String -> Maybe<&2, U32>

transport status line: first line is a code, rest is the payload

def wire.text.of source · line 21 · raw

@c:0x5e4e2a9db839a0214ace6923b04b685b/http.Cut -> String

text after the first newline

def wire.text source · line 28 · raw

@raw:String -> String

def wire.ok.of source · line 32 · raw

@m:Maybe<&2, U32> -> Bool

whether the wire status is success (0)

def wire.ok source · line 39 · raw

@raw:String -> Bool

def from.reply source · line 43 · raw

@r:0x5e4e2a9db839a0214ace6923b04b685b/http.Reply -> Response

a torn or successful HTTP parse as a client Response

def from.raw source · line 51 · raw

@raw:String -> @ok:Bool -> Response

a finished exchange

def http.talk source · line 59 · raw

@secure:Bool -> @host:String -> @port:U32 -> @req:String -> IO(Response)

HTTP(S) exchange with a pre-built request

def http.loc source · line 66 · raw

@method:String -> @l:0x5e4e2a9db839a0214ace6923b04b685b/url.Loc -> @headers:List<&2, 0x5e4e2a9db839a0214ace6923b04b685b/http.Header> -> @body:String -> IO(Response)

a URL that came apart into an HTTP exchange

def client.get source · line 76 · raw

@url:String -> @headers:List<&2, 0x5e4e2a9db839a0214ace6923b04b685b/http.Header> -> IO(Response)

GET

def client.head source · line 80 · raw

@url:String -> @headers:List<&2, 0x5e4e2a9db839a0214ace6923b04b685b/http.Header> -> IO(Response)

HEAD (RFC 9110 §9.3.2)

def client.post source · line 84 · raw

@url:String -> @headers:List<&2, 0x5e4e2a9db839a0214ace6923b04b685b/http.Header> -> @body:0x5e4e2a9db839a0214ace6923b04b685b/body.Body -> IO(Response)

POST

def client.put source · line 89 · raw

@url:String -> @headers:List<&2, 0x5e4e2a9db839a0214ace6923b04b685b/http.Header> -> @body:0x5e4e2a9db839a0214ace6923b04b685b/body.Body -> IO(Response)

PUT

def client.delete source · line 94 · raw

@url:String -> @headers:List<&2, 0x5e4e2a9db839a0214ace6923b04b685b/http.Header> -> @body:0x5e4e2a9db839a0214ace6923b04b685b/body.Body -> IO(Response)

DELETE

def client.options source · line 99 · raw

@url:String -> @headers:List<&2, 0x5e4e2a9db839a0214ace6923b04b685b/http.Header> -> IO(Response)

OPTIONS

def client.bearer source · line 103 · raw

@token:String -> 0x5e4e2a9db839a0214ace6923b04b685b/http.Header

Authorization: Bearer …

def client.basic source · line 107 · raw

@user:String -> @password:String -> 0x5e4e2a9db839a0214ace6923b04b685b/http.Header

Authorization: Basic … (RFC 7617, credentials are RFC 4648 Base64)