Separate interaces into %http-server and %http-client

A repeating patern while developing was confusion over whether an
operation was inbound or outbound. By putting this into the gift
and tasks, we can avoid this: an [%http-server %request ...] is
not an [%http-client %request ...].

(This requires corresponding vere changes since it changes the
unix/vane interface.)
This commit is contained in:
Elliot Glaysher 2019-02-05 14:05:06 -08:00
parent 6cd52154c9
commit 8570a8f3c9
3 changed files with 244 additions and 186 deletions

View File

@ -692,7 +692,9 @@
++ per-client-event ++ per-client-event
|= [[our=@p eny=@ =duct now=@da scry=sley] state=state:client] |= [[our=@p eny=@ =duct now=@da scry=sley] state=state:client]
|% |%
++ fetch :: +request: makes an external web request
::
++ request
|= [=http-request =outbound-config] |= [=http-request =outbound-config]
^- [(list move) state:client] ^- [(list move) state:client]
:: get the next id for this request :: get the next id for this request
@ -715,7 +717,7 @@
:: email discussions make it sound like fixing that might be hard, so :: email discussions make it sound like fixing that might be hard, so
:: maybe i should just live with the way it is now? :: maybe i should just live with the way it is now?
:: ::
:- [outbound-duct.state %give %http-request id `http-request]~ :- [outbound-duct.state %give %http-client %request id `http-request]~
state state
:: +receive: receives a response to an http-request we made :: +receive: receives a response to an http-request we made
:: ::
@ -794,7 +796,8 @@
:_ ~ :_ ~
:* duct.connection :* duct.connection
%give %give
%http-progress %http-client
%progress
(need response-headers.in-progress-http-request.connection) (need response-headers.in-progress-http-request.connection)
bytes-read.in-progress-http-request.connection bytes-read.in-progress-http-request.connection
expected-size.in-progress-http-request.connection expected-size.in-progress-http-request.connection
@ -826,7 +829,8 @@
u.mime-type u.mime-type
:- :~ :* duct.connection :- :~ :* duct.connection
%give %give
%http-finished %http-client
%finished
response-headers response-headers
?:(=(0 p.data) ~ `[mime data]) ?:(=(0 p.data) ~ `[mime data])
== == == ==
@ -1496,8 +1500,8 @@
:: ::
=? moves ?=([%| *] state.channel) =? moves ?=([%| *] state.channel)
:_ moves :_ moves
:+ p.state.channel %give :^ p.state.channel %give %http-server
:* %http-response %continue :* %response %continue
:: ::
^= data ^= data
:- ~ :- ~
@ -1638,7 +1642,7 @@
:: ::
++ pass-response ++ pass-response
^- [(list move) server-state] ^- [(list move) server-state]
[[duct %give %http-response raw-http-response]~ state] [[duct %give %http-server %response raw-http-response]~ state]
:: ::
++ log-complete-request ++ log-complete-request
:: todo: log the complete request :: todo: log the complete request
@ -1659,7 +1663,7 @@
:: respond to outside with %error :: respond to outside with %error
:: ::
^- [(list move) server-state] ^- [(list move) server-state]
[[duct %give %http-response %cancel ~]~ state] [[duct %give %http-server %response %cancel ~]~ state]
-- --
:: +add-binding: conditionally add a pairing between binding and action :: +add-binding: conditionally add a pairing between binding and action
:: ::
@ -1672,7 +1676,7 @@
|- |-
^- [(list move) server-state] ^- [(list move) server-state]
?~ to-search ?~ to-search
:- [duct %give %bound %.y binding]~ :- [duct %give %http-server %bound %.y binding]~
=. bindings.state =. bindings.state
:: store in reverse alphabetical order so that longer paths are first :: store in reverse alphabetical order so that longer paths are first
:: ::
@ -1688,7 +1692,7 @@
state state
:: ::
?: =(binding binding.i.to-search) ?: =(binding binding.i.to-search)
:- [duct %give %bound %.n binding]~ :- [duct %give %http-server %bound %.n binding]~
state state
:: ::
$(to-search t.to-search) $(to-search t.to-search)
@ -1839,82 +1843,72 @@
;: weld ;: weld
:: hand back default configuration for now :: hand back default configuration for now
:: ::
[duct %give %form *http-config]~ [duct %give %http-server %set-config *http-config]~
:: ::
closed-connections closed-connections
== ==
::
::
::
%http-server
=/ event-args [[our eny duct now scry-gate] server-state.ax]
=/ server (per-server-event event-args)
?- -.server-task.task
:: ::
:: %live: no idea what this is for :: %live: no idea what this is for
:: ::
%live %live
:: ::
~& [%todo-live p.task q.task] ~! task
~& [%todo-live server-task.task]
:: ::
[~ light-gate] [~ light-gate]
:: ::
:: %inbound-request: handles an inbound http request %request
=^ moves server-state.ax (request:server +.server-task.task)
[moves light-gate]
:: ::
%inbound-request %cancel-request
=^ moves server-state.ax cancel-request:server
[moves light-gate]
:: ::
:: TODO: This is uncommit %connect
::
=/ event-args [[our eny duct now scry-gate] server-state.ax]
=/ request request:(per-server-event event-args)
=^ moves server-state.ax =^ moves server-state.ax
(request +.task) %+ add-binding:server binding.server-task.task
[%app app.server-task.task]
[moves light-gate] [moves light-gate]
:: ::
:: %serve
::
%cancel-inbound-request
=/ event-args [[our eny duct now scry-gate] server-state.ax]
=/ cancel-request cancel-request:(per-server-event event-args)
=^ moves server-state.ax cancel-request
[moves light-gate]
::
:: %fetch
::
%fetch
=/ event-args [[our eny duct now scry-gate] client-state.ax]
=/ fetch fetch:(per-client-event event-args)
=^ moves client-state.ax (fetch +.task)
[moves light-gate]
::
:: %cancel-fetch
::
%cancel-fetch
~& %todo-cancel-fetch
[~ light-gate]
::
:: %receive: receives http data from unix
::
%receive
=/ event-args [[our eny duct now scry-gate] client-state.ax]
=/ receive receive:(per-client-event event-args)
=^ moves client-state.ax (receive +.task)
[moves light-gate]
::
:: %connect / %serve
::
?(%connect %serve)
=/ event-args [[our eny duct now scry-gate] server-state.ax]
=/ add-binding add-binding:(per-server-event event-args)
=^ moves server-state.ax =^ moves server-state.ax
%+ add-binding binding.task %+ add-binding:server binding.server-task.task
?- -.task [%gen generator.server-task.task]
%connect [%app app.task]
%serve [%gen generator.task]
==
[moves light-gate] [moves light-gate]
::
:: %disconnect
:: ::
%disconnect %disconnect
=/ event-args [[our eny duct now scry-gate] server-state.ax] =. server-state.ax (remove-binding:server binding.server-task.task)
=/ remove-binding remove-binding:(per-server-event event-args)
=. server-state.ax (remove-binding binding.task)
[~ light-gate] [~ light-gate]
== ==
::
::
::
%http-client
=/ event-args [[our eny duct now scry-gate] client-state.ax]
=/ client (per-client-event event-args)
?- -.client-task.task
::
%request
=^ moves client-state.ax (request:client +.client-task.task)
[moves light-gate]
::
%cancel-request
~& %todo-cancel-request
[~ light-gate]
::
%receive
=^ moves client-state.ax (receive:client +.client-task.task)
[moves light-gate]
==
==
:: ::
++ take ++ take
|= [=wire =duct wrapped-sign=(hypo sign)] |= [=wire =duct wrapped-sign=(hypo sign)]

View File

@ -1994,34 +1994,45 @@
+| %vane-interface +| %vane-interface
++ able ++ able
|% |%
:: +gift: %light responses
::
++ gift ++ gift
$% :: form: configures the http server $% [%http-server server-gift]
[%http-client client-gift]
==
:: +server-gift: effects the server can emit
::
++ server-gift
$% :: set-config: configures the external http server
:: ::
:: TODO: We need to actually return a (map (unit @t) http-config) :: TODO: We need to actually return a (map (unit @t) http-config)
:: so we can apply configurations on a per-site basis :: so we can apply configurations on a per-site basis
:: ::
:: TODO: %form is a terrible name, but it's what vere currently :: TODO: THIS WAS %form. When done renaming, be done renaming.
:: accepts. Rename it.
:: ::
[%form =http-config] [%set-config =http-config]
:: http-response: response from urbit to earth :: response: response to an event from earth
:: ::
[%http-response =raw-http-response] [%response =raw-http-response]
:: %http-request: outbound http-request to earth
::
:: TODO: id is sort of wrong for this interface; the duct should
:: be enough to identify which request we're talking about?
::
[%http-request id=@ud request=(unit http-request)]
:: response to a %connect or %serve :: response to a %connect or %serve
:: ::
:: :accepted is whether :binding was valid. Duplicate bindings are :: :accepted is whether :binding was valid. Duplicate bindings are
:: not allowed. :: not allowed.
:: ::
[%bound accepted=? =binding] [%bound accepted=? =binding]
==
:: +client-gift: effects the client can emit
::
++ client-gift
$% :: %http-request: outbound http-request to earth
::
:: TODO: id is sort of wrong for this interface; the duct should
:: be enough to identify which request we're talking about?
::
[%request id=@ud request=(unit http-request)]
:: periodically sent as an update on the duct that sent %fetch :: periodically sent as an update on the duct that sent %fetch
:: ::
$: %http-progress $: %progress
:: http-response-header: full transaction header :: http-response-header: full transaction header
:: ::
:: In case of a redirect chain, this is the target of the :: In case of a redirect chain, this is the target of the
@ -2040,7 +2051,7 @@
== ==
:: final response of a download, parsed as mime-data if successful :: final response of a download, parsed as mime-data if successful
:: ::
[%http-finished =http-response-header full-file=(unit mime-data)] [%finished =http-response-header full-file=(unit mime-data)]
== ==
:: ::
++ task ++ task
@ -2049,27 +2060,27 @@
:: TODO: Remove this once we single home. :: TODO: Remove this once we single home.
:: ::
[%init our=@p] [%init our=@p]
:: new unix process (?) :: new unix process
:: ::
[%born p=(list host)] [%born p=(list host)]
:: set http ports (?) :: task for the http server
::
[%http-server =server-task]
:: task for the http client
::
[%http-client =client-task]
==
::
++ server-task
$% :: set http ports (?)
:: ::
[%live p=@ud q=(unit @ud)] [%live p=@ud q=(unit @ud)]
:: starts handling an inbound http request :: starts handling an inbound http request
:: ::
[%inbound-request secure=? =address =http-request] [%request secure=? =address =http-request]
:: cancels a previous request :: cancels a previous request
:: ::
[%cancel-inbound-request ~] [%cancel-request ~]
:: fetches a remote resource
::
[%fetch =http-request =outbound-config]
:: cancels a previous fetch
::
[%cancel-fetch ~]
:: receives http data from outside
::
[%receive id=@ud =raw-http-response]
:: connects a binding to an app :: connects a binding to an app
:: ::
[%connect =binding app=term] [%connect =binding app=term]
@ -2083,6 +2094,18 @@
:: ::
[%disconnect =binding] [%disconnect =binding]
== ==
::
++ client-task
$% :: fetches a remote resource
::
[%request =http-request =outbound-config]
:: cancels a previous fetch
::
[%cancel-request ~]
:: receives http data from outside
::
[%receive id=@ud =raw-http-response]
==
-- --
:: ::
+| %bindings +| %bindings

View File

@ -37,8 +37,8 @@
light-gate light-gate
now=~1111.1.2 now=~1111.1.2
scry=*sley scry=*sley
call-args=[duct=~[/app1] ~ [%connect [~ /] %app1]] call-args=[duct=~[/app1] ~ [%http-server %connect [~ /] %app1]]
expected-moves=[duct=~[/app1] %give %bound %.y [~ /]]~ expected-moves=[duct=~[/app1] %give %http-server %bound %.y [~ /]]~
== ==
:: app2 tries to bind to the same path and fails :: app2 tries to bind to the same path and fails
:: ::
@ -47,8 +47,8 @@
light-gate light-gate
now=~1111.1.3 now=~1111.1.3
scry=*sley scry=*sley
call-args=[duct=~[/app2] ~ [%connect [~ /] %app2]] call-args=[duct=~[/app2] ~ [%http-server %connect [~ /] %app2]]
expected-moves=[duct=~[/app2] %give %bound %.n [~ /]]~ expected-moves=[duct=~[/app2] %give %http-server %bound %.n [~ /]]~
== ==
:: ::
;: weld ;: weld
@ -74,8 +74,8 @@
light-gate light-gate
now=~1111.1.2 now=~1111.1.2
scry=*sley scry=*sley
call-args=[duct=~[/app1] ~ [%connect [~ /] %app1]] call-args=[duct=~[/app1] ~ [%http-server %connect [~ /] %app1]]
expected-moves=[duct=~[/app1] %give %bound %.y [~ /]]~ expected-moves=[duct=~[/app1] %give %http-server %bound %.y [~ /]]~
== ==
:: app1 unbinds :: app1 unbinds
:: ::
@ -84,7 +84,7 @@
light-gate light-gate
now=~1111.1.3 now=~1111.1.3
scry=*sley scry=*sley
call-args=[duct=~[/app1] ~ [%disconnect [~ /]]] call-args=[duct=~[/app1] ~ [%http-server %disconnect [~ /]]]
expected-moves=~ expected-moves=~
== ==
:: app2 binds successfully :: app2 binds successfully
@ -94,8 +94,8 @@
light-gate light-gate
now=~1111.1.4 now=~1111.1.4
scry=*sley scry=*sley
call-args=[duct=~[/app2] ~ [%connect [~ /] %app2]] call-args=[duct=~[/app2] ~ [%http-server %connect [~ /] %app2]]
expected-moves=[duct=~[/app2] %give %bound %.y [~ /]]~ expected-moves=[duct=~[/app2] %give %http-server %bound %.y [~ /]]~
== ==
:: ::
;: weld ;: weld
@ -122,8 +122,8 @@
light-gate light-gate
now=~1111.1.2 now=~1111.1.2
scry=*sley scry=*sley
call-args=[duct=~[/app1] ~ [%connect [~ /] %app1]] call-args=[duct=~[/app1] ~ [%http-server %connect [~ /] %app1]]
expected-moves=[duct=~[/app1] %give %bound %.y [~ /]]~ expected-moves=[duct=~[/app1] %give %http-server %bound %.y [~ /]]~
== ==
:: app2 tries to steal the binding by disconnecting the path :: app2 tries to steal the binding by disconnecting the path
:: ::
@ -132,7 +132,7 @@
light-gate light-gate
now=~1111.1.3 now=~1111.1.3
scry=*sley scry=*sley
call-args=[duct=~[/app2] ~ [%disconnect [~ /]]] call-args=[duct=~[/app2] ~ [%http-server %disconnect [~ /]]]
expected-moves=~ expected-moves=~
== ==
:: app2 doesn't bind successfully because it couldn't remove app1's binding :: app2 doesn't bind successfully because it couldn't remove app1's binding
@ -142,8 +142,8 @@
light-gate light-gate
now=~1111.1.4 now=~1111.1.4
scry=*sley scry=*sley
call-args=[duct=~[/app2] ~ [%connect [~ /] %app2]] call-args=[duct=~[/app2] ~ [%http-server %connect [~ /] %app2]]
expected-moves=[duct=~[/app2] %give %bound %.n [~ /]]~ expected-moves=[duct=~[/app2] %give %http-server %bound %.n [~ /]]~
== ==
:: ::
;: weld ;: weld
@ -173,7 +173,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-blah] ~ :* duct=~[/http-blah] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
[%'GET' '/' ~ ~] [%'GET' '/' ~ ~]
@ -182,7 +183,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-blah] :~ :* duct=~[/http-blah]
%give %give
%http-response %http-server
%response
%start %start
404 404
:~ ['content-type' 'text/html'] :~ ['content-type' 'text/html']
@ -215,8 +217,8 @@
light-gate light-gate
now=~1111.1.2 now=~1111.1.2
scry=*sley scry=*sley
call-args=[duct=~[/app1] ~ [%connect [~ /] %app1]] call-args=[duct=~[/app1] ~ [%http-server %connect [~ /] %app1]]
expected-moves=[duct=~[/app1] %give %bound %.y [~ /]]~ expected-moves=[duct=~[/app1] %give %http-server %bound %.y [~ /]]~
== ==
:: outside requests a path that app1 has bound to :: outside requests a path that app1 has bound to
:: ::
@ -227,7 +229,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-blah] ~ :* duct=~[/http-blah] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
[%'GET' '/' ~ ~] [%'GET' '/' ~ ~]
@ -266,12 +269,15 @@
:* wire=/run-app/app1 duct=~[/http-blah] :* wire=/run-app/app1 duct=~[/http-blah]
^- (hypo sign:light-gate) ^- (hypo sign:light-gate)
:- *type :- *type
:^ %g %unto %http-response :* %g %unto %http-response
^- raw-http-response:light-gate %start 200
[%start 200 ['content-type' 'text/html']~ [~ (as-octs:mimes:html 'Hiya!')] %.y] ['content-type' 'text/html']~
[~ (as-octs:mimes:html 'Hiya!')]
%.y
==
== ==
^= expected-move ^= expected-move
:~ :* duct=~[/http-blah] %give %http-response :~ :* duct=~[/http-blah] %give %http-server %response
[%start 200 ['content-type' 'text/html']~ `[5 'Hiya!'] %.y] [%start 200 ['content-type' 'text/html']~ `[5 'Hiya!'] %.y]
== == == == == ==
:: ::
@ -299,8 +305,8 @@
light-gate light-gate
now=~1111.1.2 now=~1111.1.2
scry=*sley scry=*sley
call-args=[duct=~[/app1] ~ [%connect [~ /] %app1]] call-args=[duct=~[/app1] ~ [%http-server %connect [~ /] %app1]]
expected-moves=[duct=~[/app1] %give %bound %.y [~ /]]~ expected-moves=[duct=~[/app1] %give %http-server %bound %.y [~ /]]~
== ==
:: outside requests a path that app1 has bound to :: outside requests a path that app1 has bound to
:: ::
@ -311,7 +317,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-blah] ~ :* duct=~[/http-blah] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
[%'GET' '/' ~ ~] [%'GET' '/' ~ ~]
@ -349,12 +356,14 @@
^= take-args ^= take-args
:* wire=/run-app/app1 duct=~[/http-blah] :* wire=/run-app/app1 duct=~[/http-blah]
^- (hypo sign:light-gate) :- *type ^- (hypo sign:light-gate) :- *type
:^ %g %unto %http-response :* %g %unto %http-response
^- raw-http-response:light-gate %start 200 ['content-type' 'text/html']~
[%start 200 ['content-type' 'text/html']~ [~ (as-octs:mimes:html 'Hi')] %.n] [~ (as-octs:mimes:html 'Hi')]
%.n
==
== ==
^= expected-move ^= expected-move
:~ :* duct=~[/http-blah] %give %http-response :~ :* duct=~[/http-blah] %give %http-server %response
[%start 200 ['content-type' 'text/html']~ `[2 'Hi'] %.n] [%start 200 ['content-type' 'text/html']~ `[2 'Hi'] %.n]
== == == == == ==
:: theoretical outside response :: theoretical outside response
@ -367,12 +376,12 @@
^= take-args ^= take-args
:* wire=/run-app/app1 duct=~[/http-blah] :* wire=/run-app/app1 duct=~[/http-blah]
^- (hypo sign:light-gate) :- *type ^- (hypo sign:light-gate) :- *type
:^ %g %unto %http-response :* %g %unto %http-response
^- raw-http-response:light-gate
[%continue [~ (as-octs:mimes:html 'ya!')] %.y] [%continue [~ (as-octs:mimes:html 'ya!')] %.y]
== ==
==
^= expected-move ^= expected-move
:~ :* duct=~[/http-blah] %give %http-response :~ :* duct=~[/http-blah] %give %http-server %response
[%continue `[3 'ya!'] %.y] [%continue `[3 'ya!'] %.y]
== == == == == ==
:: ::
@ -403,8 +412,8 @@
light-gate light-gate
now=~1111.1.2 now=~1111.1.2
scry=*sley scry=*sley
call-args=[duct=~[/app1] ~ [%connect [~ /'~landscape'] %app1]] call-args=[duct=~[/app1] ~ [%http-server %connect [~ /'~landscape'] %app1]]
expected-moves=[duct=~[/app1] %give %bound %.y [~ /'~landscape']]~ expected-moves=[duct=~[/app1] %give %http-server %bound %.y [~ /'~landscape']]~
== ==
:: outside requests a path that app1 has bound to :: outside requests a path that app1 has bound to
:: ::
@ -415,7 +424,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-blah] ~ :* duct=~[/http-blah] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
[%'GET' '/~landscape/inner-path' ~ ~] [%'GET' '/~landscape/inner-path' ~ ~]
@ -453,12 +463,12 @@
^= take-args ^= take-args
:* wire=/run-app/app1 duct=~[/http-blah] :* wire=/run-app/app1 duct=~[/http-blah]
^- (hypo sign:light-gate) :- *type ^- (hypo sign:light-gate) :- *type
:^ %g %unto %http-response :* %g %unto %http-response
^- raw-http-response:light-gate
[%start 307 ['location' '/~/login?redirect=/~landscape/inner-path']~ ~ %.y] [%start 307 ['location' '/~/login?redirect=/~landscape/inner-path']~ ~ %.y]
== ==
==
^= expected-move ^= expected-move
:~ :* duct=~[/http-blah] %give %http-response :~ :* duct=~[/http-blah] %give %http-server %response
[%start 307 ['location' '/~/login?redirect=/~landscape/inner-path']~ ~ %.y] [%start 307 ['location' '/~/login?redirect=/~landscape/inner-path']~ ~ %.y]
== == == == == ==
:: the browser then fetches the login page :: the browser then fetches the login page
@ -479,7 +489,8 @@
^= call-args ^= call-args
^- [=duct type=* wrapped-task=(hobo task:able:light-gate)] ^- [=duct type=* wrapped-task=(hobo task:able:light-gate)]
:* duct=~[/http-blah] ~ :* duct=~[/http-blah] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
%'GET' %'GET'
@ -546,8 +557,8 @@
light-gate light-gate
now=~1111.1.2 now=~1111.1.2
scry=*sley scry=*sley
call-args=[duct=~[/gen1] ~ [%serve [~ /] [%home /gen/handler/hoon ~]]] call-args=[duct=~[/gen1] ~ [%http-server %serve [~ /] [%home /gen/handler/hoon ~]]]
expected-moves=[duct=~[/gen1] %give %bound %.y [~ /]]~ expected-moves=[duct=~[/gen1] %give %http-server %bound %.y [~ /]]~
== ==
:: outside requests a path that app1 has bound to :: outside requests a path that app1 has bound to
:: ::
@ -558,7 +569,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-blah] ~ :* duct=~[/http-blah] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
[%'GET' '/' ~ ~] [%'GET' '/' ~ ~]
@ -614,7 +626,7 @@
[%cast %mime !>([['text' 'plain' ~] (as-octs:mimes:html 'one two three')])] [%cast %mime !>([['text' 'plain' ~] (as-octs:mimes:html 'one two three')])]
== ==
^= expected-move ^= expected-move
:~ :* duct=~[/http-blah] %give %http-response :~ :* duct=~[/http-blah] %give %http-server %response
:* %start :* %start
200 200
:~ ['content-type' 'text/plain'] :~ ['content-type' 'text/plain']
@ -740,7 +752,7 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-blah] ~ :* duct=~[/http-blah] ~
%inbound-request %http-server %request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
[%'PUT' '/~/channel/1234567890abcdef' ~ ~] [%'PUT' '/~/channel/1234567890abcdef' ~ ~]
@ -749,7 +761,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-blah] :~ :* duct=~[/http-blah]
%give %give
%http-response %http-server
%response
%start %start
400 400
:~ ['content-type' 'text/html'] :~ ['content-type' 'text/html']
@ -863,7 +876,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-get-open] ~ :* duct=~[/http-get-open] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
%'GET' %'GET'
@ -875,7 +889,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-get-open] :~ :* duct=~[/http-get-open]
%give %give
%http-response %http-server
%response
%start %start
200 200
:~ ['content-type' 'text/event-stream'] :~ ['content-type' 'text/event-stream']
@ -913,7 +928,7 @@
light-gate light-gate
now=(add ~1111.1.2 ~m4) now=(add ~1111.1.2 ~m4)
scry=*sley scry=*sley
call-args=[duct=~[/http-get-open] ~ %cancel-inbound-request ~] call-args=[duct=~[/http-get-open] ~ %http-server %cancel-request ~]
^= expected-moves ^= expected-moves
^- (list move:light-gate) ^- (list move:light-gate)
:: closing the channel restarts the timeout timer :: closing the channel restarts the timeout timer
@ -951,7 +966,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-put-request] ~ :* duct=~[/http-put-request] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
%'PUT' %'PUT'
@ -985,7 +1001,7 @@
card.i.moves card.i.moves
:: ::
%+ expect-eq %+ expect-eq
!> [~[/http-put-request] %give %http-response %start 200 ~ ~ %.y] !> [~[/http-put-request] %give %http-server %response %start 200 ~ ~ %.y]
!> i.t.moves !> i.t.moves
:: ::
%+ expect-eq %+ expect-eq
@ -1063,7 +1079,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-get-open] ~ :* duct=~[/http-get-open] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
%'GET' %'GET'
@ -1075,7 +1092,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-get-open] :~ :* duct=~[/http-get-open]
%give %give
%http-response %http-server
%response
%start %start
200 200
:~ ['content-type' 'text/event-stream'] :~ ['content-type' 'text/event-stream']
@ -1120,7 +1138,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-get-open] :~ :* duct=~[/http-get-open]
%give %give
%http-response %http-server
%response
%continue %continue
:- ~ :- ~
%- as-octs:mimes:html %- as-octs:mimes:html
@ -1143,7 +1162,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-put-request] ~ :* duct=~[/http-put-request] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
%'PUT' %'PUT'
@ -1166,7 +1186,7 @@
[%leaf "wrong number of moves: {<(lent moves)>}"]~ [%leaf "wrong number of moves: {<(lent moves)>}"]~
:: ::
%+ expect-eq %+ expect-eq
!> [~[/http-put-request] %give %http-response %start 200 ~ ~ %.y] !> [~[/http-put-request] %give %http-server %response %start 200 ~ ~ %.y]
!> i.moves !> i.moves
== ==
:: the client connection is detected to be broken :: the client connection is detected to be broken
@ -1176,7 +1196,7 @@
light-gate light-gate
now=(add ~1111.1.2 ~m6) now=(add ~1111.1.2 ~m6)
scry=*sley scry=*sley
call-args=[duct=~[/http-get-open] ~ %cancel-inbound-request ~] call-args=[duct=~[/http-get-open] ~ %http-server %cancel-request ~]
^= expected-moves ^= expected-moves
^- (list move:light-gate) ^- (list move:light-gate)
:: closing the channel restarts the timeout timer :: closing the channel restarts the timeout timer
@ -1213,7 +1233,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-get-open] ~ :* duct=~[/http-get-open] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
%'GET' %'GET'
@ -1225,7 +1246,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-get-open] :~ :* duct=~[/http-get-open]
%give %give
%http-response %http-server
%response
%start %start
200 200
:~ ['content-type' 'text/event-stream'] :~ ['content-type' 'text/event-stream']
@ -1267,9 +1289,9 @@
results8 results8
results9 results9
== ==
:: +test-fetch-basic: tests a single request, single reply style http request :: +test-client-request-basic: tests a single request, single reply style http request
:: ::
++ test-fetch-basic ++ test-client-request-basic
:: send a %born event to use /initial-born-duct for requests :: send a %born event to use /initial-born-duct for requests
:: ::
=^ results1 light-gate =^ results1 light-gate
@ -1285,7 +1307,8 @@
^= expected-moves ^= expected-moves
:~ :* duct=~[/initial-born-duct] :~ :* duct=~[/initial-born-duct]
%give %give
%form %http-server
%set-config
*http-config:light *http-config:light
== == == == == ==
:: ::
@ -1304,7 +1327,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-get-request] ~ :* duct=~[/http-get-request] ~
%fetch %http-client
%request
request request
*outbound-config:light *outbound-config:light
== ==
@ -1312,7 +1336,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/initial-born-duct] :~ :* duct=~[/initial-born-duct]
%give %give
%http-request %http-client
%request
id=0 id=0
~ ~
method=%'GET' method=%'GET'
@ -1330,7 +1355,8 @@
^= call-args ^= call-args
:+ duct=~[/initial-born-duct] ~ :+ duct=~[/initial-born-duct] ~
^- task:able:light ^- task:able:light
:* %receive :* %http-client
%receive
id=0 id=0
^- raw-http-response:light ^- raw-http-response:light
:* %start :* %start
@ -1351,7 +1377,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-get-request] :~ :* duct=~[/http-get-request]
%give %give
%http-finished %http-client
%finished
:: ::
:- 200 :- 200
:~ ['content-type' 'text/html'] :~ ['content-type' 'text/html']
@ -1371,9 +1398,9 @@
results2 results2
results3 results3
== ==
:: +test-fetch-multiple-cards: tests when complete=%.n :: +test-client-request-multiple-cards: tests when complete=%.n
:: ::
++ test-fetch-multiple-cards ++ test-client-request-multiple-cards
:: send a %born event to use /initial-born-duct for requests :: send a %born event to use /initial-born-duct for requests
:: ::
=^ results1 light-gate =^ results1 light-gate
@ -1389,7 +1416,8 @@
^= expected-moves ^= expected-moves
:~ :* duct=~[/initial-born-duct] :~ :* duct=~[/initial-born-duct]
%give %give
%form %http-server
%set-config
*http-config:light *http-config:light
== == == == == ==
:: ::
@ -1408,7 +1436,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-get-request] ~ :* duct=~[/http-get-request] ~
%fetch %http-client
%request
request request
*outbound-config:light *outbound-config:light
== ==
@ -1416,7 +1445,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/initial-born-duct] :~ :* duct=~[/initial-born-duct]
%give %give
%http-request %http-client
%request
id=0 id=0
~ ~
method=%'GET' method=%'GET'
@ -1434,7 +1464,8 @@
^= call-args ^= call-args
:+ duct=~[/initial-born-duct] ~ :+ duct=~[/initial-born-duct] ~
^- task:able:light ^- task:able:light
:* %receive :* %http-client
%receive
id=0 id=0
^- raw-http-response:light ^- raw-http-response:light
:* %start :* %start
@ -1449,7 +1480,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-get-request] :~ :* duct=~[/http-get-request]
%give %give
%http-progress %http-client
%progress
:: ::
:- 200 :- 200
:~ ['content-type' 'text/html'] :~ ['content-type' 'text/html']
@ -1470,7 +1502,8 @@
^= call-args ^= call-args
:+ duct=~[/initial-born-duct] ~ :+ duct=~[/initial-born-duct] ~
^- task:able:light ^- task:able:light
:* %receive :* %http-client
%receive
id=0 id=0
^- raw-http-response:light ^- raw-http-response:light
:* %continue :* %continue
@ -1481,7 +1514,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-get-request] :~ :* duct=~[/http-get-request]
%give %give
%http-progress %http-client
%progress
:: ::
:- 200 :- 200
:~ ['content-type' 'text/html'] :~ ['content-type' 'text/html']
@ -1502,7 +1536,8 @@
^= call-args ^= call-args
:+ duct=~[/initial-born-duct] ~ :+ duct=~[/initial-born-duct] ~
^- task:able:light ^- task:able:light
:* %receive :* %http-client
%receive
id=0 id=0
^- raw-http-response:light ^- raw-http-response:light
:* %continue :* %continue
@ -1513,7 +1548,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-get-request] :~ :* duct=~[/http-get-request]
%give %give
%http-finished %http-client
%finished
:: ::
:- 200 :- 200
:~ ['content-type' 'text/html'] :~ ['content-type' 'text/html']
@ -1693,7 +1729,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-blah] ~ :* duct=~[/http-blah] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
[%'GET' '/~/login?redirect=/~landscape/inner-path' ~ ~] [%'GET' '/~/login?redirect=/~landscape/inner-path' ~ ~]
@ -1702,7 +1739,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-blah] :~ :* duct=~[/http-blah]
%give %give
%http-response %http-server
%response
%start %start
200 200
:~ ['content-type' 'text/html'] :~ ['content-type' 'text/html']
@ -1721,7 +1759,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-blah] ~ :* duct=~[/http-blah] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
%'POST' %'POST'
@ -1735,7 +1774,8 @@
^- (list move:light-gate) ^- (list move:light-gate)
:~ :* duct=~[/http-blah] :~ :* duct=~[/http-blah]
%give %give
%http-response %http-server
%response
%start %start
307 307
:~ ['location' '/~landscape'] :~ ['location' '/~landscape']
@ -1782,7 +1822,8 @@
scry=*sley scry=*sley
^= call-args ^= call-args
:* duct=~[/http-put-request] ~ :* duct=~[/http-put-request] ~
%inbound-request %http-server
%request
%.n %.n
[%ipv4 .192.168.1.1] [%ipv4 .192.168.1.1]
%'PUT' %'PUT'
@ -1829,7 +1870,7 @@
card.i.t.moves card.i.t.moves
:: ::
%+ expect-eq %+ expect-eq
!> [~[/http-put-request] %give %http-response %start 200 ~ ~ %.y] !> [~[/http-put-request] %give %http-server %response %start 200 ~ ~ %.y]
!> i.t.t.moves !> i.t.t.moves
:: ::
%+ expect-eq %+ expect-eq