[Tutor] dealing with 406 HTTP response

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Jan 17 00:52:50 CET 2007

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?


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!


does anyone know what's going on there?  Documentation on addheader can be 
found here:


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 

Good luck!

More information about the Tutor mailing list