Ticket #4779: 4779.fsockopen.post.content-headers.diff

File 4779.fsockopen.post.content-headers.diff, 693 bytes (added by DD32, 5 years ago)

Fixes POST requests to add the Content-length and Content-type headers with FSockOpen

Line 
1Index: wp-includes/http.php
2===================================================================
3--- wp-includes/http.php        (revision 8587)
4+++ wp-includes/http.php        (working copy)
5@@ -445,6 +445,10 @@
6                $strHeaders = '';
7                $strHeaders .= strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n";
8                $strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
9+               if ( ! is_null($body) ) {
10+                       $strHeaders .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
11+                       $strHeaders .= 'Content-Length: ' . strlen($body) . "\r\n";
12+               }
13 
14                if ( is_array($headers) ) {
15                        foreach ( (array) $headers as $header => $headerValue )