protected function _parseApiHeaders($reply) {
    // split headers and body
    $headers = [];
    $reply = explode("\r\n\r\n", $reply, 4);

    // check if using proxy
    $proxy_tester = strtolower(substr($reply[0], 0, 35));
    if ($proxy_tester === 'http/1.0 200 connection established'
      || $proxy_tester === 'http/1.1 200 connection established'
    ) {
      array_shift($reply);
    }

    $headers_array = explode("\r\n", $reply[0]);
    foreach ($headers_array as $header) {
      $header_array = explode(': ', $header, 2);
      $key = $header_array[0];
      $value = '';
      if (count($header_array) > 1) {
        $value = $header_array[1];
      }
      $headers[$key] = $value;
    }

    if (count($reply) > 1) {
      $reply = $reply[1];
    } else {
      $reply = '';
    }

    return [$headers, $reply];
  }
protected function _parseApiHeaders($reply) {
    // split headers and body
    $headers = [];
    $reply = explode("\r\n\r\n", $reply, 4);

    // check if using proxy
    $proxy_tester = strtolower(substr($reply[0], 0, 35));
    if ($proxy_tester === 'http/1.0 200 connection established'
      || $proxy_tester === 'http/1.1 200 connection established'
    ) {
      array_shift($reply);
    }

    $headers_array = explode("\r\n", $reply[0]);
    foreach ($headers_array as $header) {
      $header_array = explode(': ', $header, 2);
      $key = $header_array[0];
      $value = '';
      if (count($header_array) > 1) {
        $value = $header_array[1];
      }
      $headers[$key] = $value;
    }

    if (count($reply) > 1) {
      $reply = $reply[1];
    } else {
      $reply = '';
    }

    return [$headers, $reply];
  }
protected function _parseApiHeaders ( $ reply ) { // split headers and body $ headers = [ ] ; $ reply = explode ( "\r\n\r\n" , $ reply , 4 ) ; // check if using proxy $ proxy_tester = strtolower ( substr ( $ reply [ 0 ] , 0 , 35 ) ) ; if ( $ proxy_tester === 'http/1.0 200 connection established' || $ proxy_tester === 'http/1.1 200 connection established' ) { array_shift ( $ reply ) ; } $ headers_array = explode ( "\r\n" , $ reply [ 0 ] ) ; foreach ( $ headers_array as $ header ) { $ header_array = explode ( ': ' , $ header , 2 ) ; $ key = $ header_array [ 0 ] ; $ value = '' ; if ( count ( $ header_array ) > 1 ) { $ value = $ header_array [ 1 ] ; } $ headers [ $ key ] = $ value ; } if ( count ( $ reply ) > 1 ) { $ reply = $ reply [ 1 ] ; } else { $ reply = '' ; } return [ $ headers , $ reply ] ; }
Parses the API reply to separate headers from the body

@param string $reply The actual raw HTTP request reply

@return array (headers, reply)
Parses the API reply to separate headers from the body