Worldpay/Worldpay-Magento2-CG

Request headers are set incorrectly resulting in unexpected 100 Continue response

Closed this issue · 0 comments

The sendRequest() function in Model/Request.php does not correctly set the cURL request headers, which can result in an unexpected 100 response code from the Worldpay API.

By default, cURL adds a 'Expect: 100-continue' header to POST requests over 1024 bytes (source). This will cause the Worldpay API to respond with a 100 response code. This causes requests to fail due to the check on line 134 of Request.php, which expects a 200 response code.

The workaround for this to to manually set the 'Expect' header to an empty string, which is done on line 85. However, because the function then attempts to set headers again on lines 90-106, the empty 'Expect' header gets overwritten.

There is an additional error with the headers on lines 90-106 as these are formatted incorrectly so have no effect on the actual request.

I will submit a pull request shortly to rectify these issues.