You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
763 B

⟨Split,ES,SS⟩ ← •Import "helpers.bqn"
⟨Dict⟩ ← •Import "Dict.bqn"
⟨JSON⟩ ← •Import "JSON.bqn"
"--silent" # headers can be inserted here
"Accept: application/json"
s‿o‿e← •SH curl # [s]tatus std[o]ut st[e]rr
lf ← @+13‿10 # [l]ine [f]eed
h‿b ← (∾˜lf) SS o # [h]eader splits [b]ody by 2×CLRF
shlf ← lf ES h # [s]plit [h]eader on [l]ine [f]eed
stat ← <⟨"status",•Bqn 1⊑' 'Split ⊑shlf⟩ # http status parse
hs ← stat∾(<": ")SS ¨1↓shlf # key value split of headers
# return the headers Dict with the JSON body
⟨Dict 1‿2⥊⟨"headers",<>hs⟩,JSON b⟩