mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 18:12:47 +03:00
A %coup failure from gall should return a 500 to the client.
This commit is contained in:
parent
324445a7d9
commit
49319a5a7e
@ -1357,20 +1357,29 @@
|
||||
--
|
||||
:: +handle-ford-response: translates a ford response for the outside world
|
||||
::
|
||||
:: TODO: Get the authentication state and source url here.
|
||||
::
|
||||
++ handle-ford-response
|
||||
|= made-result=made-result:ford
|
||||
^- [(list move) server-state]
|
||||
::
|
||||
=+ connection=(~(got by connections.state) duct)
|
||||
::
|
||||
?: ?=(%incomplete -.made-result)
|
||||
%^ return-static-data-on-duct 500 'text/html'
|
||||
:: TODO: Thread original URL and authentication state here.
|
||||
(internal-server-error %.y 'http://' tang.made-result)
|
||||
::
|
||||
%- internal-server-error :*
|
||||
authenticated.inbound-request.connection
|
||||
url.request.inbound-request.connection
|
||||
tang.made-result
|
||||
==
|
||||
::
|
||||
?: ?=(%error -.build-result.made-result)
|
||||
%^ return-static-data-on-duct 500 'text/html'
|
||||
(internal-server-error %.y 'http://' message.build-result.made-result)
|
||||
::
|
||||
%- internal-server-error :*
|
||||
authenticated.inbound-request.connection
|
||||
url.request.inbound-request.connection
|
||||
message.build-result.made-result
|
||||
==
|
||||
::
|
||||
=/ =cage (result-to-cage:ford build-result.made-result)
|
||||
::
|
||||
@ -1387,6 +1396,21 @@
|
||||
`(unit octs)`[~ q.result]
|
||||
complete=%.y
|
||||
==
|
||||
:: +handle-gall-error: a call to +poke-http-response resulted in a %coup
|
||||
::
|
||||
++ handle-gall-error
|
||||
|= =tang
|
||||
^- [(list move) server-state]
|
||||
::
|
||||
=+ connection=(~(got by connections.state) duct)
|
||||
::
|
||||
%^ return-static-data-on-duct 500 'text/html'
|
||||
::
|
||||
%- internal-server-error :*
|
||||
authenticated.inbound-request.connection
|
||||
url.request.inbound-request.connection
|
||||
tang
|
||||
==
|
||||
:: +handle-response: check a response for correctness and send to earth
|
||||
::
|
||||
:: All outbound responses including %http-server generated responses need to go
|
||||
@ -1710,11 +1734,23 @@
|
||||
::
|
||||
++ run-app
|
||||
::
|
||||
?. ?=([%g %unto %http-response *] sign)
|
||||
:: entirely normal to get things other than http-response calls, but we
|
||||
:: don't care.
|
||||
?> ?=([%g %unto *] sign)
|
||||
::
|
||||
::
|
||||
?: ?=([%coup *] p.sign)
|
||||
?~ p.p.sign
|
||||
:: received a positive acknowledgment: take no action
|
||||
::
|
||||
[~ http-server-gate]
|
||||
:: we have an error; propagate it to the client
|
||||
::
|
||||
[~ http-server-gate]
|
||||
=/ event-args [[our eny duct now scry-gate] server-state.ax]
|
||||
=/ handle-gall-error
|
||||
handle-gall-error:(per-server-event event-args)
|
||||
=^ moves server-state.ax (handle-gall-error u.p.p.sign)
|
||||
[moves http-server-gate]
|
||||
::
|
||||
?> ?=([%g %unto %http-response *] sign)
|
||||
::
|
||||
=/ event-args [[our eny duct now scry-gate] server-state.ax]
|
||||
=/ handle-response handle-response:(per-server-event event-args)
|
||||
|
@ -285,6 +285,96 @@
|
||||
results4
|
||||
==
|
||||
::
|
||||
++ test-app-error
|
||||
::
|
||||
=^ results1 http-server-gate
|
||||
%- http-server-call :*
|
||||
http-server-gate
|
||||
now=~1111.1.1
|
||||
scry=scry-provides-code
|
||||
call-args=[duct=~[/init] ~ [%init ~nul]]
|
||||
expected-moves=~
|
||||
==
|
||||
:: app1 binds successfully
|
||||
::
|
||||
=^ results2 http-server-gate
|
||||
%- http-server-call :*
|
||||
http-server-gate
|
||||
now=~1111.1.2
|
||||
scry=scry-provides-code
|
||||
call-args=[duct=~[/app1] ~ [%connect [~ /] %app1]]
|
||||
expected-moves=[duct=~[/app1] %give %bound %.y [~ /]]~
|
||||
==
|
||||
:: outside requests a path that app1 has bound to
|
||||
::
|
||||
=^ results3 http-server-gate
|
||||
%- http-server-call-with-comparator :*
|
||||
http-server-gate
|
||||
now=~1111.1.3
|
||||
scry=scry-provides-code
|
||||
^= call-args
|
||||
:* duct=~[/http-blah] ~
|
||||
%request
|
||||
%.n
|
||||
[%ipv4 .192.168.1.1]
|
||||
[%'GET' '/' ~ ~]
|
||||
==
|
||||
^= comparator
|
||||
|= moves=(list move:http-server-gate)
|
||||
^- tang
|
||||
::
|
||||
?. ?=([* ~] moves)
|
||||
[%leaf "wrong number of moves: {<(lent moves)>}"]~
|
||||
::
|
||||
::
|
||||
=/ move=move:http-server-gate i.moves
|
||||
=/ =duct duct.move
|
||||
=/ card=(wind note:http-server-gate gift:able:http-server-gate) card.move
|
||||
::
|
||||
%+ weld
|
||||
(expect-eq !>(~[/http-blah]) !>(duct))
|
||||
::
|
||||
%+ expect-gall-deal
|
||||
:+ /run-app/app1 [~nul ~nul]
|
||||
^- cush:gall
|
||||
:* %app1 %poke %handle-http-request
|
||||
!>([%.n %.n [%ipv4 .192.168.1.1] [%'GET' '/' ~ ~]])
|
||||
==
|
||||
card
|
||||
==
|
||||
:: the poke fails. we should relay this to the client
|
||||
::
|
||||
=^ results4 http-server-gate
|
||||
%- http-server-take :*
|
||||
http-server-gate
|
||||
now=~1111.1.4
|
||||
scry=scry-provides-code
|
||||
^= take-args
|
||||
:* wire=/run-app/app1 duct=~[/http-blah]
|
||||
^- (hypo sign:http-server-gate)
|
||||
:- *type
|
||||
:* %g %unto %coup ~
|
||||
:~ [%leaf "/~zod/...../app1:<[1 1].[1 20]>"]
|
||||
== ==
|
||||
==
|
||||
^= expected-move
|
||||
:~ :* duct=~[/http-blah] %give %response
|
||||
%start
|
||||
:- 500
|
||||
:~ ['content-type' 'text/html']
|
||||
['content-length' '180']
|
||||
==
|
||||
[~ (internal-server-error:http-server-gate %.n '/' ~)]
|
||||
complete=%.y
|
||||
== == ==
|
||||
::
|
||||
;: weld
|
||||
results1
|
||||
results2
|
||||
results3
|
||||
results4
|
||||
==
|
||||
::
|
||||
++ test-multipart-app-request
|
||||
::
|
||||
=^ results1 http-server-gate
|
||||
|
Loading…
Reference in New Issue
Block a user