Change the %lient interface to have one output type.

This commit is contained in:
Elliot Glaysher 2019-02-15 12:00:10 -08:00
parent f9e112f249
commit be4bcc9698
5 changed files with 43 additions and 37 deletions

View File

@ -948,16 +948,19 @@
?~ p.cit
(he-diff %txt ">=")
(he-diff %tan u.p.cit)
:: +he-finished: result from http-client
:: +he-http-response: result from http-client
::
++ he-finished
|= [way=wire header=response-header:http full-file=(unit mime-data:http-client)]
++ he-http-response
|= [way=wire response=client-response:http-client]
^+ +>
~& [%response header full-file]
?> ?=(^ poy)
=< he-pine
?. ?=(%finished -.response)
~& %dojo-received-http-progress
+>
::
%. [%httr !>((to-httr:http-client header full-file))]
~! response
%. [%httr !>((to-httr:http-client response-header.response full-file.response))]
=+ dye=~(. dy u.poy(pux ~))
?+ way !!
{$hand ~} dy-hand:dye
@ -1182,7 +1185,7 @@
[~ +>.$]
::
++ made (wrap he-made):arm
++ finished (wrap he-finished):arm
++ http-response (wrap he-http-response):arm
++ lame (wrap he-lame):arm
++ unto (wrap he-unto):arm
++ pull

View File

@ -71,19 +71,9 @@
%+ each (unit out) :: ~ is abort
(pair sole-prompt (sole-dialog out)) :: ask and continue
:: ::
++ sole-request :: scraper result
|* out/$-(* *) :: output structure
%+ pair (list tank) ::
%+ each (unit out) :: ~ is abort
%^ trel :: fetch and continue
(unit knot)
hiss:eyre
$-(httr:eyre (sole-request out))
:: ::
++ sole-gen :: XX virtual type
$% {$say $-((sole-args) (cask))} :: direct noun
{$ask $-((sole-args) (sole-product (cask)))} :: dialog
{$get $-((sole-args) (sole-request (cask)))} :: scraper
== ::
++ sole-args :: generator arguments
|* _[* *] ::

View File

@ -198,6 +198,7 @@
:_ ~
:* duct.connection
%give
%http-response
%progress
(need response-header.in-progress-http-request.connection)
bytes-read.in-progress-http-request.connection
@ -230,6 +231,7 @@
u.mime-type
:- :~ :* duct.connection
%give
%http-response
%finished
response-header
?:(=(0 p.data) ~ `[mime data])

View File

@ -2057,28 +2057,9 @@
:: %cancel-request: tell earth to cancel a previous %request
::
[%cancel-request id=@ud]
:: periodically sent as an update on the duct that sent %fetch
:: %response: response to the caller
::
$: %progress
:: http-response-header: full transaction header
::
:: In case of a redirect chain, this is the target of the
:: final redirect.
::
=response-header:http
:: bytes-read: bytes fetched so far
::
bytes-read=@ud
:: expected-size: the total size if response had a content-length
::
expected-size=(unit @ud)
:: incremental: data received since the last %http-progress
::
incremental=(unit octs)
==
:: final response of a download, parsed as mime-data if successful
::
[%finished =response-header:http full-file=(unit mime-data)]
[%http-response =client-response]
==
::
++ task
@ -2099,6 +2080,32 @@
[%receive id=@ud =http-event:http]
==
--
:: +client-response: one or more client responses given to the caller
::
+$ client-response
$% :: periodically sent as an update on the duct that sent %fetch
::
$: %progress
:: http-response-header: full transaction header
::
:: In case of a redirect chain, this is the target of the
:: final redirect.
::
=response-header:http
:: bytes-read: bytes fetched so far
::
bytes-read=@ud
:: expected-size: the total size if response had a content-length
::
expected-size=(unit @ud)
:: incremental: data received since the last %http-progress
::
incremental=(unit octs)
==
:: final response of a download, parsed as mime-data if successful
::
[%finished =response-header:http full-file=(unit mime-data)]
==
:: mime-data: externally received but unvalidated mimed data
::
+$ mime-data

View File

@ -83,6 +83,7 @@
^- (list move:http-client-gate)
:~ :* duct=~[/http-get-request]
%give
%http-response
%finished
::
:- 200
@ -172,6 +173,7 @@
^- (list move:http-client-gate)
:~ :* duct=~[/http-get-request]
%give
%http-response
%progress
::
:- 200
@ -204,6 +206,7 @@
^- (list move:http-client-gate)
:~ :* duct=~[/http-get-request]
%give
%http-response
%progress
::
:- 200
@ -236,6 +239,7 @@
^- (list move:http-client-gate)
:~ :* duct=~[/http-get-request]
%give
%http-response
%finished
::
:- 200