~/bend-docscommunity

src/client.bend relies on unsafe/foreign

raw source on the hub · import emerging-ezhttp@0.8.0.0/src/client.bend as Client

ezhttp/src/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 ./auth.bend as Auth

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:0xf1c957a470368870a6d1d62a8c0cbe32/src/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:0xf1c957a470368870a6d1d62a8c0cbe32/src/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:0xf1c957a470368870a6d1d62a8c0cbe32/src/url.Loc -> @headers:List<&2, 0xf1c957a470368870a6d1d62a8c0cbe32/src/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, 0xf1c957a470368870a6d1d62a8c0cbe32/src/http.Header> -> IO(Response)

GET

def client.head source · line 80 · raw

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

HEAD (RFC 9110 §9.3.2)

def client.post source · line 84 · raw

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

POST

def client.put source · line 89 · raw

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

PUT

def client.delete source · line 94 · raw

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

DELETE

def client.options source · line 99 · raw

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

OPTIONS

def client.bearer source · line 103 · raw

@token:String -> 0xf1c957a470368870a6d1d62a8c0cbe32/src/http.Header

Authorization: Bearer … (auth.bend)

def client.basic source · line 107 · raw

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

Authorization: Basic … (auth.bend; RFC 7617, RFC 4648 Base64)