Skip to content

Conversation

@foglcz
Copy link

@foglcz foglcz commented Apr 26, 2013

Right now, there's no possibility to alter request headers should we need to. This pull request fixes it.

@foglcz
Copy link
Author

foglcz commented Jun 7, 2013

Bump

@djsipe
Copy link
Contributor

djsipe commented Jun 10, 2013

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.

@djsipe djsipe closed this in 36fbc8c Jun 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants