@param HeaderInterface|string $header

@return Response
10246
public function header($header)
    {
        if ($header instanceof HeaderInterface) {
            $header = $header->toString();
        }

        if (empty($header)) {
            return $this;
        }

        header((string) $header);

        return $this;
    }
332890
public function addHeader($header)
    {
        if (is_string($header)) {
            $header = HeaderField::fromString($header);
        }
        $this->headers[] = $header;
        return $this;
    }
593887
public static function getFormatByAcceptHeader($header)
    {
        if(isset(self::$mimeMapper[$header])) {
            return self::$mimeMapper[$header];
        } else {
            return self::$format;
        }
    }
1294696
private static function getHeaderClass($header)
    {
        if (true === self::isHeaderSupported($header)) {
            return self::getSupportedHeaders()[$header];
        }
        throw new \InvalidArgumentException(sprintf('Header "%s" is not supported. Please add an instance of HeaderCheckerInterface directly.', $header));
    }
616784
public function setHeader(array $header)
    {
        if (is_numeric(key($header))) {
            $header = array_fill_keys($header, '');
        }
        $this->header = $header;

        return $this;
    }
1104500
public function addResponseHeader(ResponseHeader $header, $key = '')
    {
        if (empty($key)) {
            $this->responseHeaders[] = $header->toArray();
        } else {
            $this->responseHeaders[$key] = $header->toArray();
        }

        return $this;
    }
300177
public function receiveResponseHeader($curl, $header)
    {
        static $normalize = array("\r", "\n");
        $length = strlen($header);
        $header = str_replace($normalize, '', $header);

        if (strpos($header, 'HTTP/') === 0) {

            $startLine = explode(' ', $header, 3);
            $code = $startLine[1];
            $status = isset($startLine[2]) ? $startLine[2] : '';

            // Only download the body of the response to the specified response
            // body when a successful response is received.
            if ($code >= 200 && $code < 300) {
                $body = $this->request->getResponseBody();
            } else {
                $body = EntityBody::factory();
            }

            $response = new Response($code, null, $body);
            $response->setStatus($code, $status);
            $this->request->startResponse($response);

            $this->request->dispatch('request.receive.status_line', array(
                'request'       => $this,
                'line'          => $header,
                'status_code'   => $code,
                'reason_phrase' => $status
            ));

        } elseif ($pos = strpos($header, ':')) {
            $this->request->getResponse()->addHeader(
                trim(substr($header, 0, $pos)),
                trim(substr($header, $pos + 1))
            );
        }

        return $length;
    }
75788
public function getHeader($header)
    {
        return isset($this->getHeaders()[$header]) ? $this->getHeaders()[$header] : null;
    }
236737
function replace($header)
    {
        if (is_string($header))
            $header = HeaderField::fromString($header);

        return $this
            ->remove($header->getName())
            ->add($header);
    }
1178846
private function parseHeader($header) {
        if(!empty($header)) {
            $pos = strpos($header, ": ");

            if(false !== $pos) {
                $name = substr($header,0,$pos);
                $value = substr($header,$pos+2);

                $this->headers[$name] = $value;
            }
        }
    }
934263
public function receiveResponseHeader($curl, $header)
    {
        static $normalize = ["\r", "\n"];
        $length = strlen($header);
        $header = str_replace($normalize, '', $header);

        if (strpos($header, 'HTTP/') === 0) {
            $startLine = explode(' ', $header, 3);
            // Only download the body to a target body when a successful
            // response is received.
            if ($startLine[1][0] != '2') {
                $this->body = null;
            }
            $this->statusCode = $startLine[1];
            $this->reasonPhrase = isset($startLine[2]) ? $startLine[2] : null;
            $this->protocolVersion = substr($startLine[0], -3);
            $this->headers = [];
        } elseif ($pos = strpos($header, ':')) {
            $this->headers[substr($header, 0, $pos)][] = substr($header, $pos + 1);
        } elseif ($header == '' && $this->statusCode >= 200) {
            $response = $this->messageFactory->createResponse(
                $this->statusCode,
                $this->headers,
                $this->body,
                [
                    'protocol_version' => $this->protocolVersion,
                    'reason_phrase'    => $this->reasonPhrase
                ]
            );
            $this->headers = $this->body = null;
            $this->transaction->setResponse($response);
            // Allows events to react before downloading any of the body
            RequestEvents::emitHeaders($this->transaction);
        }

        return $length;
    }
288211
private function parseHeader($header)
    {
        $res = preg_match_all('/(?:[^,"]*+(?:"[^"]*+")?)+[^,"]*+/', $header, $matches);

        if (!$res) {
            throw new InvalidHeader(sprintf('Failed to parse accept header: "%s"', $header));
        }

        return array_values(array_filter(array_map('trim', $matches[0])));
    }
1249470
public function getRequestHeader($header)
    {
        $header = str_replace('-', '_', strtoupper($header));
        $value = $this->{'HTTP_' . $header};

        if (!$value) {
            $headers = $this->getRequestHeaders();
            $value = !empty($headers[$header]) ? $headers[$header] : null;
        }

        return $value;
    }
1242661
public function assertResponseHeaderExists($header) {
        $this->requireResponse();

        try {
            Assertion::true(
                $this->response->hasHeader($header),
                sprintf('The "%s" response header does not exist.', $header)
            );
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException($e->getMessage());
        }
    }
745317
private function setHeader($header)
    {
        preg_match("'\[(.*?)\] 'si", $header, $match);
        if (!isset($match[1])) {
            throw new Exception('Unable to read datetime from header.');
        }
        $this->setDatetime($match[1]);

        $header = $this->cleanHeader($header);

        if (preg_match('/^[a-z]+.[A-Z]+:/', $header, $out)) {
            $this->setEnv($out[0]);
            $header = trim(str_replace($out[0], '', $header));
        }

        $this->header = $header;

        return $this;
    }
305962
private function parseHeader(string $header)
    {
        if (strpos($header, 'Digest') !== 0) {
            return false;
        }

        $needed_parts = [
            'nonce' => 1,
            'nc' => 1,
            'cnonce' => 1,
            'qop' => 1,
            'username' => 1,
            'uri' => 1,
            'response' => 1,
        ];

        $data = [];
        $regexp = '@('.implode('|', array_keys($needed_parts)).')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@';

        preg_match_all($regexp, substr($header, 7), $matches, PREG_SET_ORDER);

        if ($matches) {
            foreach ($matches as $m) {
                $data[$m[1]] = $m[3] ? $m[3] : $m[4];
                unset($needed_parts[$m[1]]);
            }
        }

        return empty($needed_parts) ? $data : false;
    }
201140
private function getHeaderIp(string $header)
    {
        foreach (array_reverse(array_map('trim', explode(',', $header))) as $ip) {
            if (self::isValid($ip) && !$this->isInProxiedIps($ip)) {
                return $ip;
            }
        }
    }