Last modified: 2011-03-17 15:14:43 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 T29924, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 27924 - PhpHttpRequest doesn't return response body if HTTP != 200
PhpHttpRequest doesn't return response body if HTTP != 200
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.18.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-07 20:29 UTC by Niklas Laxström
Modified: 2011-03-17 15:14 UTC (History)
3 users (show)

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


Attachments
patch to still get response body for non-200 response codes (543 bytes, patch)
2011-03-16 17:50 UTC, Bawolff (Brian Wolff)
Details

Description Niklas Laxström 2011-03-07 20:29:03 UTC
Translate extension needs the response body the detect the type of error with translation memory suggestions. It works with apparently.
Comment 1 Sam Reed (reedy) 2011-03-15 21:37:46 UTC
I'm struggling to reproduce this.

<?php
header( "ERROR: I'm a teapot!", true, 418 );
echo 'teapot!';

See below. Output from execute is hacked in on the read....


> $req = MWHttpRequest::factory( "http://192.168.0.195/teapot.php", $options );

> $status = $req->execute();
teapot!
> var_dump( $status );
object(Status)#14 (7) {
  ["ok"]=>
  bool(false)
  ["value"]=>
  int(100)
  ["successCount"]=>
  int(0)
  ["failCount"]=>
  int(0)
  ["success"]=>
  array(0) {
  }
  ["errors"]=>
  array(1) {
    [0]=>
    array(3) {
      ["type"]=>
      string(5) "error"
      ["message"]=>
      string(15) "http-bad-status"
      ["params"]=>
      array(2) {
        [0]=>
        string(3) "418"
        [1]=>
        string(6) "unused"
      }
    }
  }
  ["cleanCallback"]=>
  bool(false)
}

> var_dump( $req->getContent() );
string(7) "teapot!"
Comment 2 Bawolff (Brian Wolff) 2011-03-16 03:03:34 UTC
I also can not reproduce (tried with 404 page).

The Http::get wrapper won't return content for non-200 pages it seems, but MWHttpRequest::factory seems to work fine.
Comment 3 Bawolff (Brian Wolff) 2011-03-16 17:50:46 UTC
Created attachment 8299 [details]
patch to still get response body for non-200 response codes

After discussion on irc, turns out the issue is in PhpHttpRequest, not CurlHttpRequest.

Here's a patch that should in theory fix it, and does fix it for Nikerabbit, but doesn't work for me :(

I'm not entirely sure whats going on, but I get http-read-errors (aka $fh is null) for any request that isn't a 200.
Comment 4 Sam Reed (reedy) 2011-03-16 18:57:38 UTC
When I tried on TW, I got returned an instance of CurlHttpRequest

Weird.
Comment 5 Niklas Laxström 2011-03-16 19:05:58 UTC
Well, the Curl works now on twn, I don't know why it didn't earlier (I maybe the server needs multiple restarts for it to take action). I switched manually to php version to test the patch.
Comment 6 Sam Reed (reedy) 2011-03-16 19:20:31 UTC
That's possible, I know the webservers need bouncing after PHP modules etc are added...

If it works, it might aswell be applied minus the var_dump() and closed...
Comment 7 Sam Reed (reedy) 2011-03-17 15:14:43 UTC
Applied minus var_dump() in r84168

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


Navigation
Links