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
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 );