-
-
Save freezvd/23ccf56ce84382572dbbc2ed9b7b27dd to your computer and use it in GitHub Desktop.
WordPress "Expect" header fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* By default, cURL sends the "Expect" header all the time which severely impacts | |
* performance. Instead, we'll send it if the body is larger than 1 mb like | |
* Guzzle does. | |
*/ | |
function add_expect_header(array $arguments) | |
{ | |
$arguments['headers']['expect'] = !empty($arguments['body']) && strlen($arguments['body']) > 1048576 ? '100-Continue' : ''; | |
return $arguments; | |
} | |
add_filter('http_request_args', 'add_expect_header'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment