mirror of
https://github.com/urbit/shrub.git
synced 2024-12-03 05:43:18 +03:00
enhances outgoing http support in lib/stdio
This commit is contained in:
parent
3a3d7872d7
commit
1c98e0b819
@ -62,21 +62,27 @@
|
||||
::
|
||||
:: ----
|
||||
::
|
||||
:: HTTP requests
|
||||
:: Outgoing HTTP requests
|
||||
::
|
||||
++ send-request
|
||||
|= =request:http
|
||||
=/ m (async ,~)
|
||||
^- form:m
|
||||
=/ =card
|
||||
[%request / request *outbound-config:http-client]
|
||||
;< ~ bind:m (send-raw-card card)
|
||||
(set-raw-contract & %request ~)
|
||||
::
|
||||
++ send-hiss
|
||||
|= =hiss:eyre
|
||||
=/ m (async ,~)
|
||||
^- form:m
|
||||
=/ =card
|
||||
[%request / (hiss-to-request:html hiss) *outbound-config:http-client]
|
||||
;< ~ bind:m (send-raw-card card)
|
||||
(set-raw-contract & %request ~)
|
||||
(send-request (hiss-to-request:html hiss))
|
||||
::
|
||||
:: Wait until we get an HTTP response or cancelation
|
||||
::
|
||||
++ take-sigh-raw
|
||||
=/ m (async (unit httr:eyre))
|
||||
++ take-response-raw
|
||||
=/ m (async (unit client-response:http-client))
|
||||
^- form:m
|
||||
|= =async-input
|
||||
:^ ~ ~ ~
|
||||
@ -97,18 +103,27 @@
|
||||
[%done ~]
|
||||
::
|
||||
%finished
|
||||
[%done (some (to-httr:http-client +.response.sign))]
|
||||
[%done (some response.sign)]
|
||||
==
|
||||
:: Wait until we get an HTTP response or cancelation and unset contract
|
||||
::
|
||||
++ take-maybe-response
|
||||
=/ m (async (unit client-response:http-client))
|
||||
^- form:m
|
||||
;< rep=(unit client-response:http-client) bind:m
|
||||
take-response-raw
|
||||
;< ~ bind:m (set-raw-contract | %request ~)
|
||||
(pure:m rep)
|
||||
::
|
||||
:: Wait until we get an HTTP response and unset contract
|
||||
::
|
||||
++ take-sigh
|
||||
=/ m (async ,httr:eyre)
|
||||
++ take-response
|
||||
=/ m (async (unit client-response:http-client))
|
||||
^- form:m
|
||||
;< rep=(unit httr:eyre) bind:m take-sigh-raw
|
||||
;< ~ bind:m (set-raw-contract | %request ~)
|
||||
;< rep=(unit client-response:http-client) bind:m
|
||||
take-maybe-response
|
||||
?^ rep
|
||||
(pure:m u.rep)
|
||||
(pure:m rep)
|
||||
|= =async-input
|
||||
[~ ~ ~ %fail %http-canceled ~]
|
||||
::
|
||||
@ -117,9 +132,26 @@
|
||||
++ take-maybe-sigh
|
||||
=/ m (async (unit httr:eyre))
|
||||
^- form:m
|
||||
;< rep=(unit httr:eyre) bind:m take-sigh-raw
|
||||
;< ~ bind:m (set-raw-contract | %request ~)
|
||||
(pure:m rep)
|
||||
;< rep=(unit client-response:http-client) bind:m
|
||||
take-maybe-response
|
||||
?~ rep
|
||||
(pure:m ~)
|
||||
:: XX s/b impossible
|
||||
::
|
||||
?. ?=(%finished -.u.rep)
|
||||
(pure:m ~)
|
||||
(pure:m (some (to-httr:http-client +.u.rep)))
|
||||
::
|
||||
:: Wait until we get an HTTP response and unset contract
|
||||
::
|
||||
++ take-sigh
|
||||
=/ m (async ,httr:eyre)
|
||||
^- form:m
|
||||
;< rep=(unit httr:eyre) bind:m take-maybe-sigh
|
||||
?^ rep
|
||||
(pure:m u.rep)
|
||||
|= =async-input
|
||||
[~ ~ ~ %fail %http-canceled ~]
|
||||
::
|
||||
:: Extract body from raw httr
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user