Hi Federico, On Sat, 2007-06-23 at 19:31 +0200, Federico Galassi wrote: > On 23/giu/07, at 18:33:41, Matthew Weier O'Phinney wrote: > > > -- Federico Galassi <[EMAIL PROTECTED]> wrote > > (on Saturday, 23 June 2007, 03:49 PM +0200): > >> Hello, > >> i started to write this e-mail as a bug report. For the record, the > >> bug is: > >> --- code --- > >> $uri = "http://www.google.com/"; > >> $client = new Zend_Http_Client(); > >> $client->setUri($uri); > >> $client->request('POST'); > >> echo $client->getLastRequest(); > >> $client->request('GET'); > >> echo $client->getLastRequest(); > > > > You need to call $client->resetParameters() between subsequent > > requests. > > This is clearly indicated in the manual. > > Unfortunately, resetParameters() doesn't reset the content type, but > that would just make it a simple bug.
I will report and fix this simple bug ASAP. > Does it make sense to leave the component > in a broken state unless an action is taken by the user, even if it's stated > by > documentation? I mean, if it has to be done, why isn't it done implicitly > after > every request is made? > Yes. In my opinion, and as it seems in the opinion of everyone who has been using Zend_Http_Client in the last 6 months or so, this is perfectly Ok. There is always a trade-off between performance + flexibility, and doing things "magically" in the background for the user. Since we are writing a framework, and not an end-user application, I tend to go with performance + flexibility. I don't think that asking the programmer to call $client->resetParameters() is too much - especially because in 80% of the cases it makes sense. In most cases, one script would use a single $client object to send requests to the same server / application, using the same client-wide settings more or less (eg. Accept headers), and usually if authentication header was set, it would be used on all requests. On the other hand, if one wants to avoid this, they can always use $client->resetParameters(). If I follow your suggestion, most people who do consecutive requests will need to reset their client before every request (eg. call several functions). I don't really like that idea. There is sense in decoupling the part that builds and sends HTTP messages from the client - this way we could have a Zend_Http_Request object that can be created separately and sent over HTTP, or perhaps even resend Zend_Controller_Request_Http objects with one or two lines of code. Those who need to send consecutive requests with similar features (and do things like capture cookies and follow redirections) could use Zend_Http_Client as is. This kind of setup makes sense - but it's not going to happen in the near future, and is a major change - thus it needs to go through a full proposal cycle. Best regards, Shahar. > Thank you, > Federico >
signature.asc
Description: This is a digitally signed message part
