diff --git a/composer.json b/composer.json index dc4bde8..b0070fa 100644 --- a/composer.json +++ b/composer.json @@ -39,4 +39,4 @@ "scripts": { "phpstan": "./phpstan.phar -v" } -} \ No newline at end of file +} diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 5794b9f..3127181 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -480,6 +480,29 @@ public function setHeader($key, $value) $this->setOpt(CURLOPT_HTTPHEADER, array_values($this->_headers)); return $this; } + + /** + * Provide header information. + * + * Provide your customized optional headers. + * + * ```php + * $curl = new Curl(); + * $curl->getHeaders(); + * ``` + * + * @return array + */ + public function getHeaders() + { + $headers = []; + foreach ($this->_headers as $header) + { + $values = explode(": ", $header, 2); + $headers[trim($values[0])] = trim($values[1]); + } + return $headers; + } /** * Provide a User Agent.