This change adds the use of 2 environment variables: RAW_BODY and MAX_JSON_SIZE, allowing users to receive the
request body as a buffer (the 'raw' body) as well as the ability to set the maximum
JSON body size.
The raw body is required when processing Stripe webhooks
The max JSON body size is defaulted to a low limit from body-parser which has caused
issues with users in the past.
[X] I have raised an issue to propose this change (required)
There was some discussion in the issue linked below. I've decided to implement the change in this was so that it was a more overall change rather than adding it to a specific verb (POST) to avoid surprising results when a user sets the RAW_BODY to true, it won't be limited only to post requests.
This also means that PUT, DELETE, and GET requests will also use the raw parser, but I think that would be understood when a user creates a function and explicitly sets the RAW_BODY variable to true expecting that the raw request body will be used.
Which issue(s) this PR fixes
Fixes #191
How Has This Been Tested?
Created sample function to print request body for verifying the type received by the function code.
Using Postman, called the function with application/json request.
Description
This change adds the use of 2 environment variables:
RAW_BODY
andMAX_JSON_SIZE
, allowing users to receive the request body as a buffer (the 'raw' body) as well as the ability to set the maximum JSON body size. The raw body is required when processing Stripe webhooks The max JSON body size is defaulted to a low limit from body-parser which has caused issues with users in the past.Signed-off-by: Burton Rheutan rheutan7@gmail.com
Motivation and Context
There was some discussion in the issue linked below. I've decided to implement the change in this was so that it was a more overall change rather than adding it to a specific verb (
POST
) to avoid surprising results when a user sets theRAW_BODY
to true, it won't be limited only to post requests.This also means that
PUT
,DELETE
, andGET
requests will also use the raw parser, but I think that would be understood when a user creates a function and explicitly sets theRAW_BODY
variable totrue
expecting that the raw request body will be used.Which issue(s) this PR fixes
Fixes #191
How Has This Been Tested?
Created sample function to print request body for verifying the type received by the function code.
Using Postman, called the function with
application/json
request.{ some: 'thing' }
RAW_BODY: true
-<Buffer 7b 0a 09 22 73 6f 6d 65 22 3a 20 22 74 68 69 6e 67 22 0a 7d>
For the
MAX_JSON_SIZE
testing: I've used an example request from HugeJsonViewer example that is 1.5mbUsing Postman, called the function with a large request body:
Adding the following to the
fn1.yml
:The result was successful:
Types of changes
Impact to existing users
None as the changes are wrapped in an environment variable. Verified the function works as expected without the env vars defined or used.
Checklist:
git commit -s