Last modified: 2012-04-21 14:33:13 UTC
Currently, when creating MwHttpRequest objects, the 'method' option/parameter must match case exactly. This seems unnecessary and caused me to bang my head against the wall for a while trying to figure out why my requests weren't POSTing. Replacing lines like } elseif ( $this->method == 'POST' ) { with } elseif ( strtoupper( $this->method ) == 'POST' ) { should do the trick and be more developer friendly. Fix forthcoming.
Also, just for reference, there is precedence for this already in HttpFunctions.php: if ( strtoupper( $this->method ) == "HEAD" ) { $this->headersOnly = true; }
Alternatively, $this->method could benefit from a setter function that automatically strtoupper's the param
HTTP::request is doing a strtoupper on the method. Are you calling MWHttpRequest::factory directly?
(In reply to comment #3) > HTTP::request is doing a strtoupper on the method. Are you calling > MWHttpRequest::factory directly? Yes. Should I not be?
The HTTP class seems to be a gatekeeper for MWHttpRequest. I don't know if MWHttpRequest original intention was for it to be called directly or not, but I'd do it through HTTP.
(In reply to comment #5) > The HTTP class seems to be a gatekeeper for MWHttpRequest. I don't know if > MWHttpRequest original intention was for it to be called directly or not, but > I'd do it through HTTP. I see what you mean - however the HTTP class doesn't let me control the cookieJar in MWHttpRequest. Basically, I've put together a very lightweight (currently) single-purpose MW Api client in a MW extension which can post to remote wikis, which means I need to be able to persist login information (hence my need for the cookieJar). I'll play around a bit with the HTTP class though and see what I can/can't do. Regardless, if the MWHttpRequest is looking for $this->method in all uppercase, it probably should ensure that values are getting set in all uppercase. Defensive programming ftw.
Fixed in commit 1122ca5f8750a7e23e3f00ad7c03a19ef25f4c17 with Change-Id: Ic20e1b99dcb56b8a11cea50293ba44022e564de9 (https://gerrit.wikimedia.org/r/#change,5493)
Fixed in c5493