[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2016-06-01 Thread Martin Panter
Changes by Martin Panter : -- resolution: -> fixed stage: commit review -> resolved status: open -> closed ___ Python tracker ___

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2016-06-01 Thread Roundup Robot
Roundup Robot added the comment: New changeset 320b9a65ac07 by Martin Panter in branch '3.5': Issue #25570: Add example of customizing User-Agent via add_header() https://hg.python.org/cpython/rev/320b9a65ac07 New changeset 75dc64c8c22b by Martin Panter in branch 'default': Issue #25570: Merge

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2016-05-31 Thread Berker Peksag
Berker Peksag added the comment: add_header.patch looks good to me. Thanks Martin. -- nosy: +berker.peksag stage: patch review -> commit review versions: -Python 3.4 ___ Python tracker

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-08 Thread Christian Rickert
Christian Rickert added the comment: >>Ah, I think I see where you are coming from. I guess you aren’t intimately >>familiar with the HTTP protocol. Exactly. :) >>If you can given a specific comment line to add to a specific example, that >>might be useful. Even if you aren’t 100% sure of

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-08 Thread Martin Panter
Martin Panter added the comment: Hmm, I wonder if that OpenerDirector example is a bit obscure. Normally you would use the default urlopen() to set User-Agent, without resorting to a custom OpenerDirector. In my patch: * Included “User-Agent header _value_” in the “headers” parameter

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-06 Thread Martin Panter
Martin Panter added the comment: This change is a result of parameter checking added in Issue 22928. The colon is not meant to be part of a field name. This is what the request being sent by your example looks like in the unpatched 3.4. (I changed to localhost.) Your attempt to override the

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-06 Thread Martin Panter
Martin Panter added the comment: Sorry, it seems I missed some updates to this bug. I think the docs have enough big red warning boxes. But an explanation or short example might be good. -- stage: -> needs patch ___ Python tracker

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-06 Thread Martin Panter
Martin Panter added the comment: Ah, I think I see where you are coming from. I guess you aren’t intimately familiar with the HTTP protocol. There are various types of “headers” aka header fields, not only User-Agent, but Content-Type and others. When they suggest passing a User-Agent header,

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-06 Thread Christian Rickert
Christian Rickert added the comment: >>So I don’t think this is a valid bug or regression. What gave you the idea to >>include the colon? "We ask that if you are going to consume the API that you pass a custom User-Agent header along with your requests. The User-Agent should primarily

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-06 Thread Christian Rickert
New submission from Christian Rickert: A piece of software stopped working after the update from Python 3.4.x to 3.5 (both Linux and Windows). I found the cause in the Request.add_header("abcd","efgh") function: If the first parameter string "abcd" contains a colon (":") character, a

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-06 Thread Christian Rickert
Christian Rickert added the comment: The URL "http://requestb.in/xrbl82xr; is invalid, you'll get a "urllib.error.HTTPError: HTTP Error 404: NOT FOUND" error." Instead, please use "http://www.example.com; to confirm. -- ___ Python tracker

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-06 Thread R. David Murray
R. David Murray added the comment: This behavior change was part of a security fix, and will appear in the next version of 3.4 as well. See issue 22928. Header names may not contain colons, the colon separator is added when the header is rendered. Detecting and rejecting them guards

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-06 Thread R. David Murray
R. David Murray added the comment: By the way, that your application worked before was pure luck, here is what httplib sends in 3.4 given your test program: POST / HTTP/1.1 Accept-Encoding: identity User-Agent: Python-urllib/3.4 Connection: close Host: ..com: Content-Length: 21

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-06 Thread Christian Rickert
Christian Rickert added the comment: Hi David, Thanks for looking into this. IMHO it would be very helpful for code debugging, if "add_header" rejects invalid header arguments ad hoc. As an alternative, the documentation I used for the implementation

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-06 Thread R. David Murray
R. David Murray added the comment: I don't think the docs need updating if the ValueError is raised by add_header. The 'key' in the docs is the header name, as examples in other sections of that doc make clear. Granted you won't necessarily see that if you just read the add_header entry,

[issue25570] urllib.request > Request.add_header("abcd", "efgh") fails with character ":" in first parameter string

2015-11-06 Thread Christian Rickert
Christian Rickert added the comment: I would suggest a red warning box that informs the reader about her/his responsibility to comply with HTTP specifications - i.e. ensuring compatibility and security. -- ___ Python tracker