Commit graph

166 commits

Author SHA1 Message Date
Liangent
10ec7a1990 Make MWHttpRequest::__construct() protected.
This class is not for direct initialization, and
new MWHttpRequest(...)->execute() doesn't work at all.

Change-Id: I557723c218cd8e8f27283d01141c890263da095d
2012-07-30 23:18:44 +08:00
Antoine Musso
12e608e3d5 converts '@fixme' to '@todo FIXME'
@fixme is simply not recognized by doxygen whereas @todo is used to
generate a nice ... todo list!!

Change-Id: If956c0a164373126ce48b791d45c56962034eecd
2012-07-10 17:16:46 +02:00
Reedy
698b51118b Revert "Treat truncated HTTP requests as errors."
Caused bug 36950 among other issues

This reverts commit ded6170bd2

Change-Id: I26500896a09a9fe720dc31b3d48cdbb3cd6c8677
2012-05-21 23:10:51 +01:00
Alexandre Emsenhuber
15e9fcca01 Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: Iaebd4e253ff3b35b568e9b394231a5691445ac95
2012-05-14 19:59:58 +02:00
Krinkle
0c9a4522cc Merge "HTTP: Fix ded6170bd2, which broke all HTTP calls." 2012-05-09 06:39:09 +00:00
Aaron
e4f0c1f57b HTTP: Fix ded6170bd2, which broke all HTTP calls.
* respHeaders contains arrays for each header (should've been
  respHeaders['content-length'][0] instead of respHeaders['content-length'])
  using getResponseHeader() instead.
* This also fixes InstantCommons, which was broken by this (bug 36653).
* Also cleaned up a bit of w/s in foreign repo code while in the area.

Change-Id: I429b0a36618cc2b873077516e9c1023dc5b7d693
2012-05-09 08:35:14 +02:00
Platonides
2af392378d Typo in comment
Change-Id: Ic5e1451f86d7bcda374fd12b5a9b85fe199a7c1a
2012-05-08 23:27:21 +02:00
Platonides
ded6170bd2 Treat truncated HTTP requests as errors.
We detect such prematurely ended request when there's a Content-Length
greater than the body we got. A strict comparison would easily fail
when there was a content encoding layer, but hopefully we won't hit
a compressed request _larger_ than the original content.

See http://thread.gmane.org/gmane.org.wikimedia.mediawiki/39622
for breakage caused by truncated HTTP replies.

Change-Id: I71418424730d46a781bde5cbfda8038457ec79c5
2012-05-07 14:46:54 -07:00
awjrichards
1122ca5f87 Ensure MWHttpRequest::method gets set with strtoupper() since code
examining MWHttpRequest::method always expects its value to be
fully uppercased.

Yes, this should not be a problem if MWHttpRequest is accessed
via HTTP class, but that will not always be guaranteed.

Resolves bug 36137.

Change-Id: Ic20e1b99dcb56b8a11cea50293ba44022e564de9
2012-04-20 15:18:06 -07:00
Mark A. Hershberger
7569a6600e Avoid setting multiple Content-Type headers.
Necessary for JSON-RPC where Content-Type has to be set to
application/json on POST.

Change-Id: I0d974c98d914a22d0150a198a9f630206bb01d64
2012-03-28 14:58:44 -04:00
Aaron Schulz
1d065d50f6 r111588: refactored proxy/noProxy code slightly for simplicity 2012-02-29 00:36:40 +00:00
Tim Starling
7c44943ee4 Make userAgent also work as an option to MWHttpRequest::factory() and MWHttpRequest::__construct(), not just Http::request(). 2012-02-27 01:37:06 +00:00
Thomas Gries
adc105dac4 important fix inside HttpFunctions.php. I noticed that when you call HttpRequest::factory with noProxy=true for example inside an intranet, this is ignored in (Curl)HttpRequest because the proxy url is not cleared. This commit makes sure at lowest level - namel in the public function proxySetup() - that a optional(true) value of noProxy is observed and that it (now) also clears the proxy url. (I have been told that I am allowed to commit this patch. Please carefully review, as usual). 2012-02-15 22:40:38 +00:00
Sam Reed
76246b9bf5 More return documentation 2012-02-09 21:33:27 +00:00
Sam Reed
85bbb0b080 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 18:01:10 +00:00
Sam Reed
f619564720 * (bug 32341) Add upload by URL domain limitation. 2012-01-19 19:16:06 +00:00
Brion Vibber
2fc16ba670 Add comments explaining that the funky multiple Location headers stuff is a CURL artifact, and that the code will need updating if bug 29232 is done (high-level handling of http redirects)
Followup r94881, r106948.
2011-12-22 23:12:44 +00:00
Roan Kattouw
c5a18b323a (bug 310720) Make Http::request() (and, by extension, get() and post() as well) accept a 'userAgent' option. Patch by Chad Horohoe 2011-11-20 17:45:18 +00:00
Platonides
2af42298c1 Follow-up r101808. Use canonical class name. 2011-11-03 22:58:16 +00:00
Mark A. Hershberger
c69ddf40aa typo 2011-11-03 15:14:02 +00:00
Antoine Musso
57faa0c794 comment that isValidURI must reject file:// URI 2011-11-03 15:06:52 +00:00
Mark A. Hershberger
d379979d1a use isValidURI for redirect check 2011-11-03 14:04:01 +00:00
Sam Reed
52cd34acf5 More documentation 2011-10-29 01:53:28 +00:00
Tobias
596a9e77e8 Disable proxy for local URLs instead of using a local proxy (which might not always exist). In r61357 a comment "Not sure this makes any sense." was removed. Indeed, that comment seems to have been right :) 2011-10-28 23:02:30 +00:00
Sam Reed
abe7663d8c Documentation
Swap a lot of "@returns" to "@return"
2011-10-13 18:44:26 +00:00
Roan Kattouw
fe82ae0e27 Use wfParseUrl() instead of parse_url() in MWHttpRequest::__construct(), and check the return value for false 2011-09-08 13:53:18 +00:00
Roan Kattouw
37e3f5dff5 Move URL expansion from Http::request() (where it was put in r93820) to MWHttpRequest::__construct(). That should fix bug 30797 (UploadStash barfs on protocol-relative URLs) 2011-09-08 13:48:11 +00:00
Roan Kattouw
75681bc57a Expand some more URLs: for feeds, referers and the proxy script 2011-08-19 17:31:40 +00:00
Marooned
0102df8489 Relative values of the "Location" header are incorrect as stated in RFC, however they do happen and modern browsers support them.
This function loops backwards through all locations in order to build the proper absolute URI - Marooned at wikia-inc.com
2011-08-18 10:33:39 +00:00
Roan Kattouw
ae7d7676fb Fix r93820: PROT_ -> PROTO_ 2011-08-03 13:11:42 +00:00
Roan Kattouw
6adb2e86a5 Some random URL protocol forcing for protocol-relative URLs 2011-08-03 12:58:21 +00:00
Chad Horohoe
4f21bb309e (bug 29959) Installer fatal when cURL and allow_url_fopen is disabled and user tries to subsribe to mediawiki-announce
Really, I'm not sure about the usefulness of exploding with a MWException anytime we can't do an external request, but at least we can stop the installer from exploding :)
2011-07-18 21:56:10 +00:00
Krinkle
0e22bbc883 Reverting r91642 per CR and pending review need-patch/patch in bug 29755 2011-07-08 17:45:26 +00:00
Mark A. Hershberger
1c712a6cc6 Bug #29755: Apply patch from Vitaliy Filippov so that MW's HTTP client
respects no_proxy env setting
2011-07-07 14:56:18 +00:00
Mark A. Hershberger
20d5ed9326 follow up r89278 — remove FTP support. 2011-06-04 02:59:10 +00:00
Brion Vibber
29aedac7db Add some doc comments on Cookie::validateCookieDomain() and Http::isValidUri(), which both have some failing test cases and are incomplete 2011-06-01 22:35:03 +00:00
Mark A. Hershberger
623083aa78 Fix Bug #29231: PhpHttpRequest doesn't support HTTPS
Tested fix with PHPUnit Tests that aren't currently executed by
CruiseControl b/c they're marked “broken” till someone comes up with
some reasonable unit tests that will work for everyone.
2011-06-01 18:57:33 +00:00
Sam Reed
4065e65d03 Even more documentation in various files 2011-05-29 14:24:27 +00:00
Brion Vibber
c07ed42491 * (bug 29174) Fix regression in upload-by-URL: files larger than PHP memory limit work again
r65152 switched upload-by-URL ($wgAllowCopyUploads) to use Http / MwHttpRequest class instead of CURL directly.
While this is mostly nice, it switched from saving large files directly to a temp file to buffering them in memory, causing large files to fail when they hit the PHP memory limit.

Fix uses MwHttpRequest's callback capability to override the read handler; now appending it to the temporary file as we go, and can confirm that largish files work again; was able to upload a 64mb .ogv that previously didn't work for me: http://prototype.wikimedia.org/tmh/images/b/b2/File-Arborophila_brunneopectus_pair_feeding_-_Kaeng_Krachan.ogv

Also expanded the documentation on MwHttpRequest::setCallback to clarify the function parameters and return value for the callback (which currently matches the low-level CURL handler's callback directly).
Note that the non-CURL implementation doesn't abort the read if the callback doesn't return the expected number of bytes, but this is an immediate fatal end of request on the Curl backend. May want further cleanup.
2011-05-27 22:31:48 +00:00
Tim Starling
6fec4e3fde Revert r87635, r87637, r87639, r87643 (MW_MIN_PHP_VERSION etc.): breaks HipHop support. 2011-05-15 13:21:16 +00:00
Happy-melon
fd34d0354b * Implement MW_VERSION constant in Defines.php and use it in preference to $wgVersion. Defines.php will have been loaded anywhere that DefaultSettings.php has been loaded.
* Move the declaration of $wgFeedClasses from Defines.php to WebStart.php
2011-05-07 14:53:08 +00:00
Sam Reed
d72508dbe7 * (bug 27924) PhpHttpRequest doesn't return response body if HTTP != 200
Apply Bawolffs patch minus the var_dump()'s
2011-03-17 15:14:09 +00:00
Sam Reed
149737fb27 Kill the oldtimeout stuff, with minimum PHP being 5.2.3 2011-03-15 12:24:05 +00:00
Sam Reed
604d1e47b7 After r83879, we're requiring php 5.2.3
Remove < 5.1.7 check and related code
2011-03-15 12:00:53 +00:00
Antoine Musso
a87cc203c6 typo / space fix in HTTP class 2011-03-09 07:12:19 +00:00
Mark A. Hershberger
b3df4babc2 misc w/s cleanups, “svn diff -x-w” clean 2011-03-08 18:12:17 +00:00
Sam Reed
6f9c5532f2 Last few svn property fixes 2011-03-08 02:40:09 +00:00
Sam Reed
350fbc1371 Strip cookie classes out of the middle of HttpFunctions.php into Cookie.php using svn copy 2011-03-07 20:42:55 +00:00
Brian Wolff
65eaa9dae1 (bug 27854) Http::isValidURI is way to lax. This is a much simplified regex that accepts a subset of the previous
regex, but also accepts ftps because both cURL and php support it. It no longer accepts thing like 'foo http://bar bax'
which was my main concern

Note the previous regex kind of looks more restrictive, but is not since saying "anything not containing a space
optionally followed by anything not containing a bunch of characters including a space" is the same as saying anything
with no spaces. See also r83296. This obviously doesn't catch all cases, but I personally think its sufficient.
At the very least it is a very significant improvement over the previous version that caught almost nothing.
2011-03-06 02:43:24 +00:00
Sam Reed
fbe8a15c31 Fix typo in @param comment
Add type to CookieJar

Define $result before loop
2011-03-02 13:07:15 +00:00