Habari\CURLRequestProcessor::_headerfunction PHP Метод

_headerfunction() публичный Метод

cURL will hand each header received by the *response* to this method, so we use it to conveniently capture them for storing in case the user wants them.
public _headerfunction ( $ch, $str ) : integer
$ch resource The cURL handle from curl_init() that is executing.
$str string The header received from the response. Should always be a single header at a time.
Результат integer The length of the header. Used by cURL to report the header_size returned by the curl_getinfo() method.
    public function _headerfunction($ch, $str)
    {
        $header = trim($str);
        // don't save blank lines we might be handed - there's usually one after the headers
        if ($header != '') {
            // break the header up into field and value
            $pieces = explode(': ', $header, 2);
            if (count($pieces) > 1) {
                // if the header was a key: value format, store it keyed in the array
                $this->headers[$pieces[0]] = $pieces[1];
            } else {
                // some headers (like the HTTP version in use) aren't keyed, so just store it keyed as itself
                $this->headers[$pieces[0]] = $pieces[0];
            }
        }
        return strlen($str);
    }