educoder/pest — pull request #15 by s9tpepper (2012-04-22 04:18:45+00:00)
Title: Added an addHeader() method

-Added an addHeader() method that lets you add a header value to the Pest object before doing a get() for example.

I was trying to make a call to a third party API and I could get curl to work in a shell_exec(), I tried with both Pest() and PestXML() but each time I would get a HTTP: Basic Authorization Denied. In my curl line I was using -h 'Accept: application/xml', so I added the addHeader() method and added it to the curl_opts array and I got it to work.

ex:
require "libs/pest/Pest.php";

$pest = new Pest('http://www.somesite.com');

$pest->addHeader("Accept", "application/xml");
$pest->setupAuth("a_user_name", "a_password");

echo $pest->get('/api/path');