~/bend-docscommunity

src/redirect.bend checks

raw source on the hub · import emerging-ezhttp@0.11.0.0/src/redirect.bend as Redirect

ezhttp/src/redirect: where a GET goes after a response, pure. The client's follow loop (client.bend) sends the next GET where this module says and decides nothing itself. SPEC.md HTTP-REDIR lists what is guaranteed.

Policy: the client follows redirects for GET only, so every hop is a GET. 301, 302, 303, 307 and 308 with a Location are followed; any other status stops. A Location is either an absolute http or https URL, taken as it is, or an absolute path, resolved against the current URL's scheme, host and port. Any other Location (a relative path, //host/..., empty) stops. The client gives a chain at most redirect.max() hops.

3 imports
import Base
import ./url.bend as Url
import ./http.bend as Http

Types

type Hop source · line 16 · raw

Data

what the client does after a response

Definitions

def redirect.max source · line 21 · raw

Nat

the most hops the client follows (httpx's default is 20)

def redirect.is source · line 25 · raw

@+status:U32 -> Bool

whether a status asks the client to go elsewhere (RFC 9110 §15.4.2-9)

def redirect.absolute source · line 31 · raw

@+loc:String -> Bool

whether a Location is an absolute http or https URL

def redirect.path source · line 36 · raw

@+loc:String -> Bool

whether a Location is an absolute path: one /, not two

def redirect.join source · line 41 · raw

@l:0x86ed7e1c3039a36756163ddcb16e3a95/src/url.Loc -> @loc:String -> Maybe<&2, String>

the origin of a URL that came apart, with an absolute path after it

def redirect.target.path source · line 49 · raw

@url:String -> @loc:String -> @path:Bool -> Maybe<&2, String>

a Location once it is known whether it is an absolute path

def redirect.target.of source · line 58 · raw

@url:String -> @+loc:String -> @absolute:Bool -> Maybe<&2, String>

a Location once it is known whether it is an absolute URL

def redirect.target source · line 68 · raw

@url:String -> @+loc:String -> Maybe<&2, String>

where a Location sends a client that is at url, or None when it is not one the client follows

def redirect.hop source · line 72 · raw

@m:Maybe<&2, String> -> Hop

a resolved target as a hop

def redirect.on source · line 80 · raw

@url:String -> @+loc:String -> @moved:Bool -> Hop

a response once it is known whether its status redirects

def redirect.next source · line 89 · raw

@left:Nat -> @url:String -> @+status:U32 -> @+loc:String -> Hop

the next hop from url, after a response with status and Location loc ("" when it had none), with left hops still allowed

def redirect.plan source · line 97 · raw

@left:Nat -> @url:String -> @+status:U32 -> @headers:List<&2, 0x86ed7e1c3039a36756163ddcb16e3a95/src/http.Header> -> Hop

the next hop after a response's status and headers