[Httplib2-discuss] Optional non-'redirect following'
Status: Beta
Brought to you by:
jcgregorio
From: Rene S. <re...@pt...> - 2007-04-19 09:07:41
|
Hello, I use the library in a proxy to retrieve pages from the target servers. In this context, the automatic redirect following is no good, as the browser will not know about the redirect. Consequently, further requests will be sent to the wrong host, resulting in errors. My solution to the problem is to add a flag to the Http class, in the constructor: self.ignore_redirects = False and to change this line > if (self.follow_all_redirects or method in ["GET", "HEAD"]) or response.status == 303: to: < if (not self.ignore_redirects) and (self.follow_all_redirects or method in ["GET", "HEAD"]) or response.status == 303: Thus, the default behavior of the library remains unchanged, but gives the calling code a chance to retrieve the 'raw' reply from the server. Does it make sense to add this feature to the library? What about caching for those replies? René Schmit |