[Python-ideas] Support data: URLs in urllib
grosser.meister.morti at gmx.net
Sun Nov 4 02:54:10 CET 2012
On 11/03/2012 11:40 AM, Paul Moore wrote:
> On 2 November 2012 23:47, Mathias Panzenböck
> <grosser.meister.morti at gmx.net> wrote:
>> Which version do you think is the best for the recipe? I guess losing the
>> mediatype (and thus the charset) is not so good, therefore the version with
>> the DataResponse is better? Maybe with a note that if you don't need the
>> mediatype you can simply return an io.BytesIO as well? How does one submit a
>> doc patch anyway? Is there a hg repo for the documentation and a web
>> interface through which one can submit a pull request?
> You should probably be consistent with urllib's behaviour for other
> URLs - from the documentation of urlopen:
> This function returns a file-like object that works as a context
> manager, with two additional methods from the urllib.response module
> geturl() — return the URL of the resource retrieved, commonly used to
> determine if a redirect was followed
> info() — return the meta-information of the page, such as headers, in
> the form of an email.message_from_string() instance (see Quick
> Reference to HTTP Headers)
> Raises URLError on errors.
Ok, I added the two methods. Now there are 3 ways to get the headers:
req.headers, req.msg, req.info()
Shouldn't there be *one* obvious way to do this? req.headers?
> To create a doc patch, open a feature request on bugs.python.org and
> attach a patch. The documentation is in the core Python repository,
> from hg.python.org. You can clone that and use Mercurial to generate a
> patch, but there's no "pull request" mechanism that I know of.
More information about the Python-ideas