From 8b89f8f37538ba64f9835ee454be21e580495647 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 19 Feb 2019 13:54:03 -0500 Subject: [PATCH] MultiHttpClient: Don't relay the end-of-headers line The callback registered by CURLOPT_HEADERFUNCTION is called for the empty line that separates the headers from the body, as well as all the actual headers. In this case, the $header string will be "\r\n". It turns out that HHVM ignores a call to header() when passed a string that's empty after trimming whitespace, while Zend PHP only ignores the call when the string is empty before trimming whitespace. This later causes problems when headers_list() is used expecting all strings returned to contain a colon. Bug: T216086 Change-Id: I07937b17beb06788166266fbb1ea1bbf456761e3 --- includes/libs/MultiHttpClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/libs/MultiHttpClient.php b/includes/libs/MultiHttpClient.php index 6ce8f45f3b..536177edeb 100644 --- a/includes/libs/MultiHttpClient.php +++ b/includes/libs/MultiHttpClient.php @@ -384,7 +384,7 @@ class MultiHttpClient implements LoggerAwareInterface { curl_setopt( $ch, CURLOPT_HEADERFUNCTION, function ( $ch, $header ) use ( &$req ) { - if ( !empty( $req['flags']['relayResponseHeaders'] ) ) { + if ( !empty( $req['flags']['relayResponseHeaders'] ) && trim( $header ) !== '' ) { header( $header ); } $length = strlen( $header ); -- 2.20.1