HTTP method override feature for web-servers that don't allow PUT and DELETE #307
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.
Added HTTP method override feature for web-servers that restrict HTTP method to GET and POST only (don't allow PUT and DELETE)
Some web-servers restrict HTTP methods to only GET and POST. Woo-Commerce uses PUT and DELETE in its API. But there are 2 workarounds for such servers:
Both variants are equivalent. And they can even be used together. This fork adds possibility to use these workarounds.
More information on this can be found here:
All you need to do to activate workaround is to add 1 or 2 options to constructor of the Client like in this example:
The options
method_override_query
activates?_method=PUT/DELETE
workaround. And the optionmethod_override_header
activates workaround withX-HTTP-Method-Override
header. Usually it's enough to activate only one of them, but you can activate they both if you want.If you want to better understand how it's working on Woo-Commerce side, you can review the code in the file
class-wc-api-server.php
. At the moment this code looks like this: