Commit Graph

49 Commits

Author SHA1 Message Date
Jeremy Hylton 1868d7c221 Add simple unittests for Request 2008-12-09 21:03:10 +00:00
Facundo Batista eb90b788f4 Issue #2776: fixed small issue when handling an URL with double slash
after a 302 response in the case of not going through a proxy.
2008-08-16 14:44:07 +00:00
Facundo Batista 4f1b1ed975 Fixed the semantic of timeout for socket.create_connection and
all the upper level libraries that use it, including urllib2.
Added and fixed some tests, and changed docs correspondingly.
Thanks to John J Lee for the patch and the pusing, :)
2008-05-29 16:39:26 +00:00
Amaury Forgeot d'Arc 9686585a82 Issue #2670: urllib2.build_opener() failed when two handlers
derive the same default base class.

Will backport.
2008-04-22 21:14:41 +00:00
Georg Brandl 331243270d #2136: allow single quotes in realm spec. 2008-03-21 19:54:00 +00:00
Christian Heimes c5f05e45cf Patch #2167 from calvin: Remove unused imports 2008-02-23 17:40:11 +00:00
Facundo Batista 86371d61b7 Fixes Issue 1401. When redirected, a possible POST get converted
to GET, so it loses its payload. So, it also must lose the
headers related to the payload (if it has no content any more,
it shouldn't indicate content length and type).
2008-02-07 19:06:52 +00:00
Georg Brandl f91149e4a1 Patch #1752270, #1750931: complain if urllib2 add_handler called
without handler.
2007-07-12 08:05:45 +00:00
Facundo Batista 10951d51e2 Added an optional timeout parameter to function urllib2.urlopen,
with tests in test_urllib2net.py (must have network resource
enabled to execute them). Also modified test_urllib2.py because
testing mock classes must take it into acount. Docs are also
updated.
2007-06-06 17:15:23 +00:00
Facundo Batista 9fab9f103f As specified in RFC 2616, 2xx code indicates that the client's
request was successfully received, understood, and accepted.
Now in these cases no error is raised. Also fixed tests.
2007-04-23 17:08:31 +00:00
Georg Brandl ceede5c359 Patch #1668100: urllib2 now correctly raises URLError instead of
OSError if accessing a local file via the file:// protocol fails.
2007-03-13 08:14:27 +00:00
Georg Brandl 8c036ccf93 Patch #1542948: fix urllib2 header casing issue. With new test. 2006-08-20 13:15:39 +00:00
Georg Brandl 0619a329e8 Bug #1459963: properly capitalize HTTP header names. 2006-07-26 07:40:17 +00:00
Georg Brandl 261e251df8 Patches #1497027 and #972322: try HTTP digest auth first,
and watch out for handler name collisions.
2006-05-29 20:52:54 +00:00
Georg Brandl 2b33037611 Patch #1496206: urllib2 PasswordMgr ./. default ports 2006-05-28 20:23:12 +00:00
Armin Rigo a3f092751a ("Forward-port" of r46506)
Remove various dependencies on dictionary order in the standard library
tests, and one (clearly an oversight, potentially critical) in the
standard library itself - base64.py.

Remaining open issues:
 * test_extcall is an output test, messy to make robust
 * tarfile.py has a potential bug here, but I'm not familiar
   enough with this code.  Filed in as SF bug #1496501.
 * urllib2.HTTPPasswordMgr() returns a random result if there is more
   than one matching root path.  I'm asking python-dev for
   clarification...
2006-05-28 19:13:17 +00:00
Georg Brandl b5f2e5cc50 Patch #1479302: Make urllib2 digest auth and basic auth play together. 2006-05-08 17:36:08 +00:00
Georg Brandl 1b06a1d4e3 Move network tests from test_urllib2 to test_urllib2net. 2006-05-03 05:15:10 +00:00
Georg Brandl fa42bd7af4 Patch #1470846: fix urllib2 ProxyBasicAuthHandler. 2006-04-30 07:06:11 +00:00
Neal Norwitz b902f4e401 Use absolute imports 2006-04-03 04:45:34 +00:00
Tim Peters 480725d4c5 Whitespace normalization. 2006-04-03 02:46:44 +00:00
Georg Brandl 720096a6bf Patch #1462790: fix urllib2 ProxyHandler for host:port proxies 2006-04-02 20:45:34 +00:00
Georg Brandl dd2245f230 Bug #1250170, Patch #1462230: handle socket.gethostname()
failures gracefully
2006-03-31 17:18:06 +00:00
Georg Brandl 80bb2bb7eb Revert r43399. 2006-03-28 19:19:56 +00:00
Georg Brandl f1349cd05d Bug #1459963: urllib2 now normalizes HTTP header names correctly
with title().
2006-03-28 12:40:24 +00:00
Tim Peters 2a8ec996ce test_gopher(): Squash another deprecation
warning about gopherlib.
2006-02-19 05:09:00 +00:00
Georg Brandl 4cbd1e3fc1 Move test case for HTTP response dict to httplib. 2006-02-17 22:01:08 +00:00
Georg Brandl e1b13d2019 Bug #735248: Fix urllib2.parse_http_list. 2005-08-24 22:20:32 +00:00
Tim Peters f5f32b4712 Whitespace normalization. 2005-07-17 23:16:17 +00:00
Georg Brandl 5c5fe2f445 RFE [ 1216944 ] Add Error Code Dictionary to urllib2 2005-07-14 06:40:47 +00:00
Jeremy Hylton 5d9c3031c8 Fix urllib2.urlopen() handling of chunked content encoding.
The change to use the newer httplib interface admitted the possibility
that we'd get an HTTP/1.1 chunked response, but the code didn't handle
it correctly.  The raw socket object can't be pass to addinfourl(),
because it would read the undecoded response.  Instead, addinfourl()
must call HTTPResponse.read(), which will handle the decoding.

One extra wrinkle is that the HTTPReponse object can't be passed to
addinfourl() either, because it doesn't implement readline() or
readlines().  As a quick hack, use socket._fileobject(), which
implements those methods on top of a read buffer.  (suggested by mwh)

Finally, add some tests based on test_urllibnet.

Thanks to Andrew Sawyers for originally reporting the chunked problem.
2004-08-07 17:40:50 +00:00
Kurt B. Kaiser 3f7cb5d9f5 Patch [ 972332 ] urllib2 FTPHandler bugs / John J. Lee
Modified Files:
	urllib2.py test/test_urllib2.py
2004-07-11 17:14:13 +00:00
Andrew M. Kuchling 85064ffd76 [Patch #988602] Move the urllib2 tests into the test framework 2004-07-10 19:46:40 +00:00
Tim Peters 27f883687b Whitespace normalization. 2004-07-08 04:22:35 +00:00
Andrew M. Kuchling 31352c5a30 Remove unused import. (If it's there for some deep, dark reason, it should have been commented.) 2004-06-29 13:17:29 +00:00
Andrew M. Kuchling bd3200fa2b Add test case for bug #912845: requesting an HTTP byte range doesn't work 2004-06-29 13:15:46 +00:00
Martin v. Löwis 2a6ba9097e Patch #963318: Add support for client-side cookie management. 2004-05-31 18:22:40 +00:00
Jeremy Hylton b3ee6f9921 Fix two bugs in the new do_open() implementation for HTTPHandler.
Invoke the standard error handlers for non-200 responses.

Always supply a "Connection: close" header to prevent the server from
leaving the connection open.  Downstream users of the socket may
attempt recv()/read() with no arguments, which would block if the
connection were kept open.
2004-02-24 19:40:35 +00:00
Tim Peters 58eb11cf62 Whitespace normalization. 2004-01-18 20:29:55 +00:00
Jeremy Hylton e708fbd286 Remove methods that are no longer called by urllib2. 2003-12-17 20:47:28 +00:00
Jeremy Hylton df38ea9c29 Add methods to MockHTTPClass for modern httplib interface.
Replace lots of assert_(x == y) with assertEqual(x, y).
2003-12-17 20:42:38 +00:00
Jeremy Hylton c1be59f40a SF patch 852995: add processors feature to urllib2
John J. Lee writes: "the patch makes it possible to implement
functionality like HTTP cookie handling, Refresh handling,
etc. etc. using handler objects. At the moment urllib2's handler
objects aren't quite up to the job, which results in a lot of
cut-n-paste and subclassing. I believe the changes are
backwards-compatible, with the exception of people who've
reimplemented build_opener()'s functionality -- those people would
need to call opener.add_handler(HTTPErrorProcessor).

The main change is allowing handlers to implement
methods like:

http_request(request)
http_response(request, response)

In addition to the usual

http_open(request)
http_error{_*}(...)
"

Note that the change isn't well documented at least in part because
handlers aren't well documented at all.  Need to fix this.

Add a bunch of new tests.  It appears that none of these tests
actually use the network, so they don't need to be guarded by a
resource flag.
2003-12-14 05:27:34 +00:00
Barry Warsaw 04f357cffe Get rid of relative imports in all unittests. Now anything that
imports e.g. test_support must do so using an absolute package name
such as "import test.test_support" or "from test import test_support".

This also updates the README in Lib/test, and gets rid of the
duplicate data dirctory in Lib/test/data (replaced by
Lib/email/test/data).

Now Tim and Jack can have at it. :)
2002-07-23 19:04:11 +00:00
Guido van Rossum e2ae77b8b8 SF patch #474590 -- RISC OS support 2001-10-24 20:42:55 +00:00
Tim Peters 83e7ccc9fd Whitespace normalization. 2001-09-04 06:37:28 +00:00
Jack Jansen 535c524508 A quick hack to make the test pass on the Mac (similar to the quick hack
to make it pass on Windows:-).
2001-08-27 22:31:58 +00:00
Tim Peters 861adac23e This has never worked on Windows. Now it does. If it breaks on Unix now,
great, it's your turn to watch it fail for months <0.9 wink>.
2001-07-16 20:49:49 +00:00
Tim Peters 3a2ab1ab69 Whitespace normalization. 2001-05-29 06:06:54 +00:00
Jeremy Hylton e3e61049a5 Trivial tests of urllib2 for recent SF bug 2001-05-09 15:50:25 +00:00