Re: dealing with 406 HTTP response (fwd)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: dealing with 406 HTTP response (fwd)

Danny Yoo


---------- Forwarded message ----------
Date: Wed, 17 Jan 2007 02:08:48 +0100
From: Tsila Hassine <[hidden email]>
To: Danny Yoo <[hidden email]>
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 <[hidden email]> 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!
>
_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: dealing with 406 HTTP response (fwd)

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


Hi Tsila,

When you have time, you may want to take a closer look at how HTTP works.
Here's one place you can look:

     http://www.jmarshall.com/easy/http/

If you are writing applications for HTTP, you should have a good idea of
basic fundamentals.  Otherwise, your code may look weird.


> 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 ?

Without seeing what you're doing in terms of code, I can't say anything
really concrete.  I do not know what you mean by "overriding", because I
don't know what your understanding is.  In other words, I don't know if
we've come to terms yet.  Show the group the code you've written, and we
can continue from there.


(I hesitate to say anything because what you're saying about class
overriding sorta sounds like you've done inheritance, but other things
that you say aren't meshing with what I'm expecting.  Better to see what's
actually happening rather than take a guess...)


By the way, when you reply to messages on Tutor, please use your email
client's "Reply to All" feature.  It'll keep the rest of the group in the
loop and give others the chance to respond.
_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Loading...