Last modified: 2012-04-21 14:33:13 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T38137, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 36137 - $this->method should be string case agnostic in MwHttpRequest classes
$this->method should be string case agnostic in MwHttpRequest classes
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-20 21:42 UTC by Arthur Richards
Modified: 2012-04-21 14:33 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Arthur Richards 2012-04-20 21:42:10 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.
Comment 1 Arthur Richards 2012-04-20 21:44:14 UTC
Also, just for reference, there is precedence for this already in HttpFunctions.php:
		if ( strtoupper( $this->method ) == "HEAD" ) {
			$this->headersOnly = true;
		}
Comment 2 Arthur Richards 2012-04-20 21:45:34 UTC
Alternatively, $this->method could benefit from a setter function that automatically strtoupper's the param
Comment 3 Platonides 2012-04-20 21:48:57 UTC
HTTP::request is doing a strtoupper on the method. Are you calling MWHttpRequest::factory directly?
Comment 4 Arthur Richards 2012-04-20 21:53:17 UTC
(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?
Comment 5 Platonides 2012-04-20 21:57:13 UTC
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.
Comment 6 Arthur Richards 2012-04-20 22:02:29 UTC
(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.
Comment 8 Platonides 2012-04-21 14:33:13 UTC
Fixed in c5493

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links