enhances outgoing http support in lib/stdio
::
:: ----
::
-:: HTTP requests
+:: Outgoing HTTP requests
::
-++ send-hiss
- |= =hiss:eyre
+++ send-request
+ |= =request:http
=/ m (async ,~)
^- form:m
=/ =card
- [%request / (hiss-to-request:html hiss) *outbound-config:http-client]
+ [%request / request *outbound-config:http-client]
;< ~ bind:m (send-raw-card card)
(set-raw-contract & %request ~)
::
+++ send-hiss
+ |= =hiss:eyre
+ =/ m (async ,~)
+ ^- form:m
+ (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
:^ ~ ~ ~
[%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 ~]
::
++ 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
::
