[Tutor] dealing with 406 HTTP response (fwd)

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Jan 17 02:18:25 CET 2007



---------- Forwarded message ----------
Date: Wed, 17 Jan 2007 02:08:48 +0100
From: Tsila Hassine <tsila.hassine at gmail.com>
To: Danny Yoo <dyoo at hkn.eecs.berkeley.edu>
Subject: Re: [Tutor] dealing with 406 HTTP response

Danny - thanks! it works though I am not sure I fully understand what i did
:-)

I am iverriding teh opener class with my fancy one, then creatign an opener
instance of it, and then i am specifying the addheader method you mentioned.
is that the right way to do it (well - it works) - and what did i just do in
terms of class overriding ?

thanks a lot for your help!
Tsila

On 1/17/07, Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:
>
>
>
> On Tue, 16 Jan 2007, Tsila Hassine wrote:
>
>> has anybody dealt with a 406 reponse through a urllib.FancyURLopener
>> class ? I have a code that downloads images from websites and soemsites
>> respond with an 406 which I don't know how to handle
>
> Hi Tsila,
>
> Have you looked at the description of a 406 error?
>
>      http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
>
> What's going on is that FancyURLOpener doesn't specify the types it can
> accept, so by default, the types of things are quite limited.
>
>
> You'll want to look into the addheader() method of your FancyURLOpener to
> reassure the web server that you will accept anything from them, by adding
> a permissive Accept: header.  For example:
>
>      opener.addheader('Accept', '*/*')
>
> should add a 'Accept:' header that eats everything.
>
>
> But for some reason, it appears that this method isn't documented in the
> Standard Library!
>
>     http://www.python.org/doc/lib/urlopener-objs.html
>
> does anyone know what's going on there?  Documentation on addheader can be
> found here:
>
> http://pydoc.org/2.4.1/urllib.html#FancyURLopener-addheader
>
> but the method should really be included in the API docs.
>
> I'll send a ping to the Documentation folks and see if this will be
> amended.
>
>
> Good luck!
>


More information about the Tutor mailing list