Last modified: 2011-09-22 01:15:28 UTC
While testing bug 29147, I noticed that the upload-by-URL handling doesn't seem to handle HTTP 302 redirects, at least for large files. A direct link to this Fedora ISO download chugs through for a while before predictably timing out: http://fedora.mirror.lstn.net/releases/15/Fedora/x86_64/iso/Fedora-15-x86_64-DVD.iso "Error fetching URL: Operation timed out after 25000 milliseconds with 62264250 out of 3596310528 bytes received" But if I copy this redirect link from Fedora's download page, it immediately gives an 'empty file' error: http://download.fedoraproject.org/pub/fedora/linux/releases/15/Fedora/x86_64/iso/Fedora-15-x86_64-DVD.iso "The file you uploaded seems to be empty. This might be due to a typo in the file name. Please check whether you really want to upload this file." Inspecting the MWHttpRequest result shows that it's found the 302 redirect, but doesn't seem to have followed it. Link found from http://fedoraproject.org/en/get-fedora-all
I think this would do the trick ? Index: upload/UploadFromUrl.php =================================================================== --- upload/UploadFromUrl.php (revision 88965) +++ upload/UploadFromUrl.php (working copy) @@ -128,7 +128,8 @@ * size and set $mRemoveTempFile to true. */ protected function reallyFetchFile() { - $req = MWHttpRequest::factory( $this->mUrl ); + $options = array( 'followRedirects' => true ); + $req = MWHttpRequest::factory( $this->mUrl, $options ); $status = $req->execute(); if ( !$status->isOk() ) {
I'd think so. We need to set a limit to the maximum number of redirects though.
* - maxRedirects Maximum number of redirects to follow (defaults to 5)
5 sounds reasonable.
Why doesn't MWHttpRequest follow redirects by default? It seems like it'd be very rare that you would not want it to.
(In reply to comment #5) > Why doesn't MWHttpRequest follow redirects by default? It seems like it'd be > very rare that you would not want it to. see r67684
Done in r97777 roughly as in comment 1 :)