|
Hi,
I'd like to propose a change to the Zend\Http component. Currently I'm working on my WebDav proposal and the Zend\Http\Request class is holding me back a bit. The Request::setMethod checks if the HTTP method is defined in the class. If not an exception is thrown. The HTTP protocol is quite flexible coming to HTTP methods as can be read here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.1 My suggestion is to remove the check at line 150 in Zend\Http\Request and just allow any value. I'd also like to remove the constants starting from line 14. The reason for this is that it is shorter to write "POST" than "Request::METHOD_POST" and of course to allow flexibility. Having constants implies that these are the only methods that can be used. Links: https://github.com/zendframework/zf2/blob/master/library/Zend/Http/Request.php#L150 https://github.com/zendframework/zf2/blob/master/library/Zend/Http/Request.php#L14 http://framework.zend.com/wiki/display/ZFDEV2/RFC+-+WebDav Regards, Walter |
|
I'd actually prefer the constants in the HTTP/Request class.
If I were do to a WebDav client class, it would presumably have a WebDav/Request extends Http/Request with an overridden setMethod() that accounts for the added extensions specific to WebDav usage, which is an extension to HTTP protocol. And in reality, the webdev request should probably be more feature rich than the http/request class. These additions probably shouldn't really apply to the majority of the common case HTTP requests. I for one like the constants, if only for IDE auto-completion, and the less magic-values the better for consistancy across code. Would rather not have to define my own class just to hold the HTTP_* constants for requests, since our coding standards prevent any literal strings from appearing in code for any reason. And it's good practise to prevent someone trying to debug ->setMethod('psot') someplace;. On Sat, Apr 21, 2012 at 1:00 PM, Walter Tamboer <[hidden email]> wrote:
|
|
This post has NOT been accepted by the mailing list yet.
In reply to this post by Walter Tamboer
The same goes for Response::setStatusCode [1].
Twitter [2] (Search and Trends API) will return a 420 status code (instead of 429) when you are being rate limited and with the current implementation I'm forced to extend the Response class to allow a more flexile status code handling. [1] https://github.com/zendframework/zf2/blob/master/library/Zend/Http/Response.php#L335 [2] https://dev.twitter.com/docs/error-codes-responses |
|
Administrator
|
In reply to this post by Walter Tamboer
-- Walter Tamboer <[hidden email]> wrote
(on Saturday, 21 April 2012, 10:00 PM +0200): > I'd like to propose a change to the Zend\Http component. Currently I'm working > on my WebDav proposal and the Zend\Http\Request class is holding me back a bit. > > The Request::setMethod checks if the HTTP method is defined in the class. If > not an exception is thrown. The HTTP protocol is quite flexible coming to HTTP > methods as can be read here: http://www.w3.org/Protocols/rfc2616/ > rfc2616-sec5.html#sec5.1.1 > > My suggestion is to remove the check at line 150 in Zend\Http\Request and just > allow any value. I'd also like to remove the constants starting from line 14. > The reason for this is that it is shorter to write "POST" than > "Request::METHOD_POST" and of course to allow flexibility. Having constants > implies that these are the only methods that can be used. I'd prefer that you extend the Request object for the WebDAV client to add additional constants for the additional request methods WebDAV supports. Since WebDAV is an _extension_ of HTTP, this seems like the more appropriate way forward. -- Matthew Weier O'Phinney Project Lead | [hidden email] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc |
| Powered by Nabble | Edit this page |
