From 37b45247262808c8d55ada42cec8fa2792d09370 Mon Sep 17 00:00:00 2001 From: Padraic Brady Date: Sun, 8 Mar 2015 21:06:40 +0000 Subject: [PATCH] Update README --- README.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b26aaf7..0f086f4 100644 --- a/README.md +++ b/README.md @@ -44,4 +44,32 @@ actually the point ;). An error should have two causes: * The URI requested could not be verified, i.e. in a browser this would be a red page warning. Neither is, in any way, a justification for disabling SSL/TLS and leaving end users vulnerable -to getting hacked. Resolve such errors; don't ignore or workaround them. \ No newline at end of file +to getting hacked. Resolve such errors; don't ignore or workaround them. + +###Headers + +You can set request headers, and get response headers, using the following functions. +This support is based around stream contexts, but is offered in some limited form +here as a convenience. If your needs are going to extend this, you should use a +more complete solution and double check that it fully enables and supports TLS. + +```php +/** + * Don't end headers with \r\n when setting via array + */ +humbug_set_headers(array( + 'Accept-Language: da', + 'User-Agent: Humbug' +)); +$response = humbug_get_contents('http://www.example.com'); +``` + +Request headers are emptied when used, so you would need to reset on each +`humbug_get_contents()` call. + +To retrieve an array of the last response headers: + +```php +$response = humbug_get_contents('http://www.example.com'); +$headers = humbug_get_headers(); +``` \ No newline at end of file