mirror of
https://github.com/urbit/shrub.git
synced 2024-11-27 18:34:48 +03:00
eyre: allow PUTting empty channel-request list
Previously, we would reject this with a 400 error. Considering the request body is expected to contain "array of requests" and that arrays may be empty, we really should not be rejecting the requests. Prior to 156ca21472, sending the empty array would have been convenient for channel creation. Empty arrays getting rejected forced clients to inject a faux poke (commonly hi-ing oneself). With that recent change, the most common case for wanting to PUT the empty list of requests is largely obsolete, but one can still imagine it being useful for clients that want to keep their channel alive without necessarily being connected to it. This also implements sloppier clients from running into 400 responses when they submit an empty "command queue" for whatever. Regardless, there seems to be no clear reason why the empty request list _shouldn't_ be accepted and processed as normal. We add a small test to ensure eyre accepts this.
This commit is contained in:
parent
4affae8181
commit
34148f9f44
@ -2372,11 +2372,6 @@
|
||||
?: ?=(%| -.maybe-requests)
|
||||
%^ return-static-data-on-duct 400 'text/html'
|
||||
(error-page 400 & url.request (trip p.maybe-requests))
|
||||
:: while weird, the request list could be empty
|
||||
::
|
||||
?: =(~ p.maybe-requests)
|
||||
%^ return-static-data-on-duct 400 'text/html'
|
||||
(error-page 400 %.y url.request "empty list of actions")
|
||||
:: check for the existence of the channel-id
|
||||
::
|
||||
:: if we have no session, create a new one set to expire in
|
||||
|
@ -757,6 +757,18 @@
|
||||
=/ mov-2 (ex-channel-response ~)
|
||||
(expect-moves mos mov-1 mov-2 ~)
|
||||
::
|
||||
++ test-channel-put-zero-requests
|
||||
%- eval-mare
|
||||
=/ m (mare ,~)
|
||||
;< ~ bind:m perform-init-start-channel-2
|
||||
;< ~ bind:m (wait ~m1)
|
||||
;< mos=(list move) bind:m
|
||||
(put '/~/channel/0123456789abcdef' cookie '[]')
|
||||
=/ mov-1 ex-204
|
||||
=/ mov-2 (ex-rest /channel/timeout/'0123456789abcdef' ~1111.1.2..12.00.00)
|
||||
=/ mov-3 (ex-wait /channel/timeout/'0123456789abcdef' ~1111.1.2..12.01.00)
|
||||
(expect-moves mos mov-1 mov-2 mov-3 ~)
|
||||
::
|
||||
++ test-channel-results-before-open
|
||||
%- eval-mare
|
||||
=/ m (mare ,~)
|
||||
|
Loading…
Reference in New Issue
Block a user