Basho\Riak\Api\Http::responseHeaderCallback PHP Méthode

responseHeaderCallback() public méthode

Handles callback from curl when the response is received, it parses the headers into an array sets them as member of the class. Has to be public for curl to be able to access it.
public responseHeaderCallback ( $ch, $header ) : integer
$ch
$header
Résultat integer
    public function responseHeaderCallback($ch, $header)
    {
        if (strpos($header, ':')) {
            list($key, $value) = explode(':', $header, 2);
            $value = trim($value);
            if (!empty($value)) {
                if (!isset($this->responseHeaders[$key])) {
                    $this->responseHeaders[$key] = $value;
                } elseif (is_array($this->responseHeaders[$key])) {
                    $this->responseHeaders[$key] = array_merge($this->responseHeaders[$key], [$value]);
                } else {
                    $this->responseHeaders[$key] = array_merge([$this->responseHeaders[$key]], [$value]);
                }
            }
        }
        return strlen($header);
    }