summaryrefslogtreecommitdiffstats
path: root/Lib/urllib2.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix two bugs in the new do_open() implementation for HTTPHandler.Jeremy Hylton2004-02-241-6/+17
| | | | | | | | | 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.
* Patch #711838: Allow non-anonymous ftp urls in urllib2.Martin v. Löwis2004-02-151-6/+15
| | | | Backported to 2.3.
* Patch #817379: Allow for absolute ftp paths.Martin v. Löwis2004-02-151-1/+1
| | | | Backported to 2.3.
* Whitespace normalization.Tim Peters2004-01-181-7/+7
|
* Rewrite AbstractHTTPHandler to use modern httplib interface.Jeremy Hylton2003-12-171-25/+26
| | | | | | | | | | | | The chief benefit of this change is that requests will now use HTTP/1.1 instead of HTTP/1.0. Bump the module version number as part of the change. There are two possible incompatibilities that we'll need to watch out for when we get to an alpha release. We may get a different class of exceptions out of httplib, and the do_open() method changed its signature. The latter is only important if anyone actually subclasses AbstractHTTPHandler.
* Remove __del__ methods to avoid creating uncollectable cyclic trash.Jeremy Hylton2003-12-151-13/+4
| | | | | | Keep close() methods for backwards compatibility. Does any call close() explicitly?
* SF patch 852995: add processors feature to urllib2Jeremy Hylton2003-12-141-56/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Apply patch 823328 -- support for rfc 2617 digestion authentication.Jeremy Hylton2003-10-211-44/+96
| | | | | | | | | | | | The patch was tweaked slightly. It's get a different mechanism for generating the cnonce which uses /dev/urandom when possible to generate less-easily-guessed random input. Also rearrange the imports so that they are alphabetical and duplicates are eliminated. Add a few XXX comments about things left undone and things that could be improved.
* Fix a bunch of typos in documentation, docstrings and comments.Walter Dörwald2003-10-201-1/+1
| | | | (From SF patch #810751)
* SF patch [ 816787 ] urllib2.URLError don't calll IOError.__init__Jeremy Hylton2003-10-061-1/+5
| | | | Not sure if this fix is great, but it's probably a small improvement.
* Patch 549151, rev4: redirect posts for 301 also. Will backport to 2.2.Martin v. Löwis2003-07-121-5/+5
|
* Fix wrong header name. The framework looks for auth_header.Jeremy Hylton2003-07-101-8/+10
|
* Change all header strings to be as if they were capitalize()'ed. Also callBrett Cannon2003-06-171-9/+9
| | | | | | capitalize in AbstractHTTPHandler before inserting headers into HTTP instance. Closes bug #649742, again.
* Whitespace normalization.Tim Peters2003-06-151-1/+1
|
* Patch #754340: Fix typo in redirect_request. Will backport to 2.2.Martin v. Löwis2003-06-141-1/+1
|
* - urllib2.py now knows how to order proxy classes, so the user doesn'tGustavo Niemeyer2003-06-071-11/+24
| | | | | | have to insert it in front of other classes, nor do dirty tricks like inserting a "dummy" HTTPHandler after a ProxyHandler when building an opener with proxy support.
* iteritems() should not have been used for self.timeout which changes during ↵Raymond Hettinger2003-05-231-1/+1
| | | | the loop.
* To be on the safe side, backed out any questionable iteritem changes and set ↵Brett Cannon2003-05-181-2/+2
| | | | back to item calls.
* Revert some changes back to dict.items made in a previous patch.Brett Cannon2003-05-171-2/+2
|
* Remove assert that checked if a parameter was an instance of Request. ↵Brett Cannon2003-05-121-1/+0
| | | | Closes patch #639139.
* Change Request.add_header to call string.capitalize in order to normalizeBrett Cannon2003-05-121-7/+8
| | | | | | headers and not have any dependency on case. Closes patch #649742. Also changed all instances of dict.items to dict.iteritems where appropriate.
* Better fix for newurl as suggested by Jim Jewett in SF bug #730963.Jeremy Hylton2003-05-051-12/+2
|
* Add comment explaining try/except for endheaders().Jeremy Hylton2003-05-051-0/+2
|
* Repair redirect handling and raise URLError on host-not-found.Jeremy Hylton2003-05-041-22/+36
| | | | | | | | | | | | | | The latest changes to the redirect handler couldn't possibly have been tested, because they did not compute a newurl and failed with a NameError. The __name__ == "__main__": block has a test for redirects. Also, fix SF bug 723831. A urlopen() that failed because the host was not found raised a socket.gaierror unlike earlier versions of urllib2. The problem is that httplib actually establishes the connection at a different point starting with Python 2.2. Move the try/except to endheaders(), which is where the connection gets established.
* SF Patch 549151: urllib2 POSTs on redirectRaymond Hettinger2003-04-241-4/+34
| | | | (contributed by John J Lee)
* Fix NameError exception ('name' undefined)Andrew M. Kuchling2002-11-061-0/+1
|
* Typo in docstringJeremy Hylton2002-10-111-1/+1
|
* Fix for SF bug #599836: Don't duplicate headers.Jeremy Hylton2002-10-111-2/+3
| | | | | If the request object has a header, it should override the default header provided by the OpenerDirector.
* SF #614596, fix for urllib2.AbstractBasicAuthHandler, John Williams (johnw42)Neal Norwitz2002-10-091-1/+1
| | | | Make the regex case insensitive for some web sites which use Realm.
* Remove ugly irregular spaces from in front of some comments.Fred Drake2002-08-131-3/+3
|
* Whitespace normalization.Tim Peters2002-07-161-2/+2
|
* Fix from SF patch #527518: proxy config with user+pass authentication.Jeremy Hylton2002-07-071-3/+8
| | | | Bug fix candidate.
* Fix HTTPError __init__ for cases where fp is None.Jeremy Hylton2002-06-031-2/+6
| | | | | | | | | | | | | | | | | | | | | The HTTPError class tries to act as a regular response objects for HTTP protocol errors that include full responses. If the failure is more basic, like no valid response, the __init__ choked when it tried to initialize its superclasses in addinfourl hierarchy that requires a valid response. The solution isn't elegant but seems to be effective. Do not initialize the base classes if there isn't a file object containing the response. In this case, user code expecting to use the addinfourl methods will fail; but it was going to fail anyway. It might be cleaner to factor out HTTPError into two classes, only one of which inherits from addinfourl. Not sure that the extra complexity would lead to any improved functionality, though. Partial fix for SF bug # 563665. Bug fix candidate for 2.1 and 2.2.
* Remove uses of the string and types modules:Walter Dörwald2002-06-031-4/+3
| | | | | | | | | | | | | | | | | | | | | | x in string.whitespace => x.isspace() type(x) in types.StringTypes => isinstance(x, basestring) isinstance(x, types.StringTypes) => isinstance(x, basestring) type(x) is types.StringType => isinstance(x, str) type(x) == types.StringType => isinstance(x, str) string.split(x, ...) => x.split(...) string.join(x, y) => y.join(x) string.zfill(x, ...) => x.zfill(...) string.count(x, ...) => x.count(...) hasattr(types, "UnicodeType") => try: unicode except NameError: type(x) != types.TupleTuple => not isinstance(x, tuple) isinstance(x, types.TupleType) => isinstance(x, tuple) type(x) is types.IntType => isinstance(x, int) Do not mention the string module in the rlcompleter docstring. This partially applies SF patch http://www.python.org/sf/562373 (with basestring instead of string). (It excludes the changes to unittest.py and does not change the os.stat stuff.)
* SF 563203. Replaced 'has_key()' with 'in'.Raymond Hettinger2002-06-011-10/+10
|
* Use types.StringTypes instead of (types.StringType, types.UnicodeType) --Michael W. Hudson2002-05-201-2/+2
| | | | | | works better (at all!) in --disable-unicode builds. Bugfix candidate, probably.
* Partial introduction of bools where appropriate.Guido van Rossum2002-04-071-4/+4
|
* Patch #525870: Avoid duplicate stat calls, use st_ attributes.Martin v. Löwis2002-03-181-4/+2
|
* Fix bug #511786 (2.2.1 candidate): ensure that custom-supplied headersGreg Ward2002-02-111-1/+1
| | | | are preserved for redirected requests.
* Fix SF bug 468948 & 451295: urllib2 authentication problemsJeremy Hylton2001-11-091-28/+12
| | | | | | | | | | | | | | | | | | | Fix contributed by Jeffrey C. Ollie. I haven't tested the fix because the situation is non-trivial to reproduce. The basic solution is to get rid of the __current_realm attribute of authentication handlers. Instead, prevent infinite retries by checking for the presence of an Authenticate: header in the request object that exactly matches the Authenticate: header that would be added. The problem prevent authentication from working correctly in the presence of retries. Ollie mentioned that digest authentication has the same problem and I applied the same solution there.
* Clean up one comment, fix typos in others.Fred Drake2001-11-081-7/+7
|
* Fix [ #465502 ] urllib2: urlopen unicode problemJeremy Hylton2001-10-091-67/+36
| | | | | | | | When checking for strings use, ! if isinstance(uri, (types.StringType, types.UnicodeType)): Also get rid of some dodgy code that tried to guess whether attributes were callable or not.
* Add content-type header to ftp URLs (SF patch #454553)Jeremy Hylton2001-08-271-4/+13
| | | | | | | | Modify rfc822.formatdate() to always generate English names, regardless of locale. This is required by RFC 1123. In open_local_file() of urllib and urllib2, use new formatdate() from rfc822.
* SF patch #454553 by Walter Dörwald: add content-type to FTP URLs, likeGuido van Rossum2001-08-241-4/+7
| | | | for urllib.
* Replace all type comparisons with isinstance() callsJeremy Hylton2001-08-111-9/+9
|
* Whitespace normalization.Tim Peters2001-08-091-1/+1
|
* Fix SF bug [ #447370 ] typo in urllib2.pyJeremy Hylton2001-08-071-7/+9
| | | | | | | | | Also fix another bug caught by pychecker-- HTTPError() raised when redirect limit exceed did not pass an fp object. Had to change method to keep fp object around until it's certain that the error won't be raised. Remove useless line in do_proxy().
* Patch #444359: Remove unused imports.Martin v. Löwis2001-08-021-1/+0
|
* Only write out one blank line before the request data.Fred Drake2001-07-041-1/+1
| | | | This closes SF patch #419459.
* Raise useful exception when called with URL for which request typeJeremy Hylton2001-05-091-1/+2
| | | | | | cannot be determined. Pseudo-fix for SF bug #420724