-
Notifications
You must be signed in to change notification settings - Fork 19
How to handle client POST requests #251
Comments
How important is POST support? |
so far we didn't have any requests for it... (giving some context: I wrote this originally in #235, when I thought we need to change the entire POST processing in order to support the live-review case. after I finished writing, I realized that the live-review POSTs directly to the action; so those changes would not be needed right now.) |
I think for the time being, we can use POSTs straight to the action. I'd only enable POSTs for |
I see 2 challenges for live previewing: POST and CORS. The Chrome extension POC POST to the action was used in the POC at Maybe an authoring client like the Chrome extension could auto-extract the action URL using a request with If we were to allow POSTs via Fastly - which we eventually may have to in order to support customer use cases like form submits - we’d also need to think when to send the proper CORS headers on both OPTIONS and POST requests, either all the time (probably not recommended) or if in certain config is present... In any case, I think we’ll have to revisit the fact that the html pipe returns whatever body it gets sent... A safer solution as suggested by @lkrapf would be to use a dedicated pipe for live previewing, which would always return the html wrapped in json, and with CORS headers. |
I think the whole how-do-I-initialize-the-live-preview question should be discussed somewhere else (e.g: getting the correct action AND content repository tuple)
agreed. |
For live previews in particular, we could also build a new request type in VCL that still does the action resolution but simply passes through the entire POST body. This would be almost equivalent to calling the action directly, but save us from URL strangeness. |
github uses media types via the
|
The Based on the |
Closed during backlog grooming session during hackathon. Reopen if needed or open a new one. |
(copied over from #235)
In general, we have to decide how (and if) we want to handle
POST
requests. eitherapplication/json
bodies,application/x-www-form-urlencoded
andmultipart/form-data
.Fastly
currently, any
POST
requests to fastly are not allowed. the internal action delegation makes heavy use of request parameters, which are manifested in the actionsparams
eg:So even if we allow
POST
requests, we have to ensure that they don't override those params. so any handling of form-param, or JSON bodies MUST NOT override any action param.Openwhisk
Currently, we deploy the actions as normal web actions. one cool feature of them is that:
As mentioned above, this behaviour is not desired, as it conflicts with the way we invoke the actions via fastly.
as a consequence, we SHOULD deploy the script as raw actions with
--web=raw
. this would imply that that pipeline needs to handle the__ow_query
parsing.Pipeline
Given the pre-conditions above, using
raw
web actions would imply to handle the__ow_query
in the pipeline (openwhisk.js) and decode them into theaction.params
.for a
POST
request with content-typeapplication/x-www-form-urlencoded
, we SHOULD decode them into thecontext.request.params
property, since they specify client input.for a
POST
request with content-typemultipart/form-data
, the pipeline COULD handle the form data and populatecontext.request.params
, or maybe acontext.request.formdata
to provide access to the binaries in some form.for a
POST
request with content-typeapplication/json
, the pipeline SHOULD decode the json body and populatecontent.request.body
for a
POST
request with any other content-type, the pipeline SHOULD keep the raw data incontent.request.body
asBuffer
. this way, application code can easily check withBuffer.isBuffer()
for raw data.Simulator
The helix simulator not only emulates fastly, but also the openwhisk gateway. so any changes to the above, need to be reflected in the simulator:
__ow_query
instead of populating actions params__ow_body
with base64 encoded request.body forPOST
requestsThe text was updated successfully, but these errors were encountered: