[issue2868] Problem with urllib and urllib2 in urlopen?

2008-05-17 Thread Martin McNickle

Martin McNickle [EMAIL PROTECTED] added the comment:

I verified the behaviour but this is a problem with that particular
site, not with urllib/urllib2.

Should be closed.

--
nosy: +BitTorment

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2868
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2824] zipfile to handle duplicate files in archive

2008-05-13 Thread Martin McNickle

Martin McNickle [EMAIL PROTECTED] added the comment:

The mechanism for throwing an error has been written, however for the
case of a duplicated filename, it appears to have been deliberatly not
been used by the original author.:

 def _writecheck(self, zinfo):
Check for errors before writing a file to the archive.
if zinfo.filename in self.NameToInfo:
if self.debug:  # Warning for duplicate names
print Duplicate name:, zinfo.filename
if self.mode not in (w, a):
raise RuntimeError, 'write() requires mode w or a'
...

Putting a 'replace=True' switch seems a little clumsy, it would be much
better to raise an error, or allow the user a way to globally control
what happens in this case, i.e. overwrite the existing file or drop it.
 Adding a global behaviour switch seems to be the best way to preserve
backwards compatibility.

What do people think is the best way?

-- Martin

--
nosy: +BitTorment

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2824
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2756] urllib2 add_header fails with existing unredirected_header

2008-05-11 Thread Martin McNickle

Changes by Martin McNickle [EMAIL PROTECTED]:


Added file: http://bugs.python.org/file10280/add_header_complete.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2756
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2756] urllib2 add_header fails with existing unredirected_header

2008-05-11 Thread Martin McNickle

Changes by Martin McNickle [EMAIL PROTECTED]:


Removed file: http://bugs.python.org/file10201/add_header_complete.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2756
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2756] urllib2 add_header fails with existing unredirected_header

2008-05-06 Thread Martin McNickle

Martin McNickle [EMAIL PROTECTED] added the comment:

I decided that the user should have full control over the headers sent.
 Any call to add_header() or add_redirected_header() will now check if a
header with that same name has been set in the Request before (in both
the header and the unredirected header dictionaries), and if so
overwrite it.

The tests run fine with the patch installed, and also included is a
patch for the urllib2 documentation.

--
keywords: +patch
Added file: http://bugs.python.org/file10200/add_header_complete.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2756
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2756] urllib2 add_header fails with existing unredirected_header

2008-05-06 Thread Martin McNickle

Changes by Martin McNickle [EMAIL PROTECTED]:


Removed file: http://bugs.python.org/file10200/add_header_complete.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2756
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2756] urllib2 add_header fails with existing unredirected_header

2008-05-06 Thread Martin McNickle

Changes by Martin McNickle [EMAIL PROTECTED]:


Added file: http://bugs.python.org/file10201/add_header_complete.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2756
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2275] urllib2 header capitalization

2008-05-06 Thread Martin McNickle

Martin McNickle [EMAIL PROTECTED] added the comment:

This looks good.  I would suggest that the unredirected_hdrs would use
the CaseInsensitiveDict too.

There is still the problem (from the test documentation) that accessing
.headers directly will only show a subset of headers i.e. it won't show
any headers from .unredirected_hdrs.  Have you any suggestions as to how
they both can be accessed from the same interface?

The test documentation also says:

Note the case normalization of header names here, to
.capitalize()-case.  This should be preserved for
backwards-compatibility.  (In the HTTP case, normalization to
.title()-case is done by urllib2 before sending headers to
httplib).

It suggests that capitalize() should be kept for backwards
compatibility.  I have tested and the headers actually sent to the
server are in title()-case even though they are stored in the Request
object as captitalize()-case.

This would initially suggest that the case-normalization should be
removed from the patch.  However, as .headers would now be using a
case-insensitive dictionary, this would still ensure backwards compatibily.

--
nosy: +BitTorment

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2275
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2776] urllib2.urlopen() gets confused with path with // in it

2008-05-06 Thread Martin McNickle

Martin McNickle [EMAIL PROTECTED] added the comment:

The problem lines are in AbstractHTTPHandler.do_request():

scheme, sel = splittype(request.get_selector())
sel_host, sel_path = splithost(sel)
if not request.has_header('Host'):
request.add_unredirected_header('Host', sel_host or host)

When there is a double '/' sel is something like '//path/to/resource'. 
splithost(sel) then gives ('path', '/to/resource').  Therefore the
header 'Host' gets set to 'path'.

I don't understand why sel_host is used in preference for host.  host
holds the correct value, even with the double slashes.  Could someone
explain why sel_host is used at all?

--
nosy: +BitTorment

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2776
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2776] urllib2.urlopen() gets confused with path with // in it

2008-05-06 Thread Martin McNickle

Changes by Martin McNickle [EMAIL PROTECTED]:


--
components: +Library (Lib) -Extension Modules
versions: +Python 2.6, Python 3.0

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2776
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2756] urllib2 add_header fails with existing unredirected_header

2008-05-05 Thread Martin McNickle

Martin McNickle [EMAIL PROTECTED] added the comment:

I can see that there will be a problem in this case.

However, it may be that the authors found it more intuitive to always
set the Content-Type to application/x-www-form-urlencoded when data is set.

Their implementation is inconsistent though:

#---
request = urllib2.Request('http://www.somesite.com/')
request.add_data(data)
f = urllib2.urlopen(request)

# 'Content-Type: application/x-www-form-urlencoded' is sent in the header
#---

whereas:

#---
request = urllib2.Request('http://www.somesite.com/')
request.add_header('Content-Type', 'application/xml')
request.add_data(data)

# 'Content-Type: application/xml' is sent in the header
#---

We need to decide what is the best way to handle this case.  Should the
normal headers be given preference, or should the unredirected headers
be given preference?

--- Martin

--
nosy: +BitTorment

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2756
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2756] urllib2 add_header fails with existing unredirected_header

2008-05-05 Thread Martin McNickle

Martin McNickle [EMAIL PROTECTED] added the comment:

Sorry, the first example should read:

#---
request = urllib2.Request('http://www.whompbox.com/headertest.php')
request.add_data(data)
f = urllib2.urlopen(request)

request.add_header('Content-Type', 'application/xml')
f = urllib2.urlopen(request)

# 'Content-Type: application/x-www-form-urlencoded' is sent in both
headers.  Second header (should?) be 'application/xml'
#---

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2756
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2695] Ignore case when checking algorithm in urllib2

2008-05-04 Thread Martin McNickle

Martin McNickle [EMAIL PROTECTED] added the comment:

RFC2617 says that the authentication scheme should be case insensitive.
 Included is a patch which changes the string to uppercase before
comparison.

--
keywords: +patch
nosy: +BitTorment
Added file: http://bugs.python.org/file10189/case_insensitive_algorithm.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2695
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com