Focus on urllib2 for this, it works quite well. Do not mess with httplib , this is not a top level API.
What you notice is that urllib2 does not follow the redirect.
You need to add an instance of HTTPRedirectHandler that will catch and follow the redirects.
In addition, you might want to subclass the default HTTPRedirectHandler to collect information, which you then check as part of testing your device.
cookie_handler= urllib2.HTTPCookieProcessor( self.cookies ) redirect_handler= HTTPRedirectHandler() opener = urllib2.build_opener(redirect_handler,cookie_handler)
You can then use this opener object for POST and GET, properly handling redirects and cookies.
You might want to add your own subclass of HTTPHandler to record and register various error codes.
S.Lott Nov 19 '08 at 14:52 2008-11-19 14:52
source share