Commits

Anonymous committed 0644f39

fix issue #6. added 'origin_url' in Response object. So you could easyly know if there
was any redirection by comparate their hash for example.

Comments (0)

Files changed (2)

restclient/transport/_curl.py

             headers.setdefault('Expect', '100-continue')
 
         # encode url
-        url = iri2uri(to_bytestring(url))
+        origin_url = to_bytestring(url)
+        url = iri2uri(origin_url)
 
         c = pycurl.Curl()
         try:
 
             response_headers = self._parseHeaders(header)
             code = c.getinfo(pycurl.RESPONSE_CODE)
-            return self._make_response(final_url=url, status=code,
-                    headers=response_headers, body=data.getvalue())
+            return self._make_response(final_url=url, origin_url=origin_url,
+                    status=code, headers=response_headers, body=data.getvalue())
         finally:
             c.close()
 
-    def _make_response(self, final_url=None, status=None, headers=None,
-            body=None):
+    def _make_response(self, final_url=None, origin_url=None, status=None, 
+            headers=None, body=None):
         infos = headers or {}    
         final_url = infos.get('location', final_url)
         infos.update({
             'status': status,
-            'final_url': final_url
+            'final_url': final_url,
+            'origin_url': origin_url
         })
         resp = HTTPResponse(infos)
         return resp, body

restclient/transport/_httplib2.py

             final_url = url
             
         httplib2_response['final_url'] = final_url
+        httplib2_response['origin_url'] = url
         resp = HTTPResponse(httplib2_response)
         return resp, content