Bugs item #971965, was opened at 2004-06-13 05:00
Message generated for change (Comment added) made by jjlee
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=971965&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Ed Watkeys (edw)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib2 raises exception with non-200 success codes.

Initial Comment:
If a server returns a code other than 200, specifically 201 
(Created), urllib2.urlopen will raise an HTTPError exception. I ran 
into this while implementing an Atom API client, which solicits 201 
responses from the server when submitting a blog post.

  File "/usr/local/lib/python2.3/urllib2.py", line 129, in urlopen
    return _opener.open(url, data)
  File "/usr/local/lib/python2.3/urllib2.py", line 326, in open
    '_open', req)
  File "/usr/local/lib/python2.3/urllib2.py", line 306, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.3/urllib2.py", line 901, in http_open
    return self.do_open(httplib.HTTP, req)
  File "/usr/local/lib/python2.3/urllib2.py", line 895, in do_open
    return self.parent.error('http', req, fp, code, msg, hdrs)
  File "/usr/local/lib/python2.3/urllib2.py", line 352, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python2.3/urllib2.py", line 306, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.3/urllib2.py", line 412, in 
http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 201: Created


----------------------------------------------------------------------

Comment By: John J Lee (jjlee)
Date: 2005-05-19 21:05

Message:
Logged In: YES 
user_id=261020

Before bug 912845 (CVS rev 1.69) added 206 to the list of
response codes considered "successful" by urllib2, I'd
assumed this would never be altered, for
backwards-compatibility reasons.

Note that this behaviour can be configured by module users,
since HTTPError exceptions support the urllib2 response
interface.  This can be done by replacing
HTTPErrorProcessor, or by replacing HTTPDefaultErrorHandler,
or catching the exception "manually".

But maybe since the 206 issue was considered a valid bug
fix, this is OK too.

If so, it would be best if the other 20x responses were also
considered at the same time. 


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=971965&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to