Closed foglcz closed 11 years ago
Bump
I like the idea of passing the headers into the get/put/post/delete methods as a third argument. Creating a method for setting headers for all requests seems like it would lead to a lot of gotchas when you try to run the second request and carry over the headers from your first request.
Taking a step back, it seems to me that there might be cause to break the core Pest class into two different classes in some version 2 of the project. One class would just be a wrapper around curl
representing a "request", the other would be the "client" allowing you to manipulate the request using a simpler API than curl
's native API.
Something like this?:
$Pest = new \Pest("http:\\example.com");
$data = $Pest->get("/user")
->data(array("name" => "joe"))
->header("Accept", "application/xml")
->run();
So in the example above get()
would really be a factory method for creating a new request that can be built upon and ultimately ran with the run()
method. It's a lot more verbose but it would provide a ton of flexibility.
Right now, there's no possibility to alter request headers should we need to. This pull request fixes it.