[Bug] honor original request method even if it's called from lookup #434
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rate-limiting module creates a Request Settings that is turned into the below VCL code:
This would break Magento site functionalities since Fastly Varnish has surprising behavior where any request method except POST is being overwritten to GET if
return(lookup)
is called for the request.So once this rate-limiting module is enabled, request methods such as DELETE, PUT, etc no longer work as expected and the origin server receives transformed GET requests instead.
To work around this, we stash the original request method in recv and restore it in miss if rate-limit module is enabled for the request. This would cause all request methods that are not defined as cacheable in RFC to be cached, which is bad. But since we also have this snippet in fetch:
https://github.com/fastly/fastly-magento2/blob/master/etc/vcl_snippets_rate_limiting/fetch.vcl#L1-L11
only 429 response is cached and all other status codes are forced to be PASS. So we should be fine with this change.