Examples
banshee/examples-collection/examples/protocols/
http-get-headers
Example: http.get with headers=, and the headers of the answer; an API that answers JSON.
by banshee1 installation1 version
Published on October 27, 2026. First version in this collection.
Protocol: http.get with headers
headers= sends headers with the request; $answer['headers'] holds those of the answer. Here, the collector asks an API for JSON and checks that it answers in JSON.
How to read it
headers=array('Accept' => 'application/json', 'Cache-Control' => 'no-cache'): a name and a value per header, sent as written. A header written in the call wins over the one banshee would send (User-Agent).- In the answer, each header name is in lowercase:
content-type, whatever the server wrote. A header sent twice by the server comes as one value, joined by,. text.split($type, ';')cutsapplication/json; charset=utf-8at the;, andtext.trimtakes the blanks off.headers=is a named argument: it comes after the address, aserrors=,user=andpassword=do, in any order.
To adapt it
- Read another header:
locationfor a redirection,last-modified,x-ratelimit-remaining. - A token in a header:
headers=array('Authorization' => 'Bearer ' . $token)(seeexamples/api/backup-jobs).