This is what I want.
- Submit a POST request to a external site(i.e login information).
- Receive the response
- Return the raw response to my client’s browser(containing the cookies for login
validation). - If the client tries to access the site in new tab he finds that he is already signed in.
I successfully completed steps 1 & 2 (submitted POST & received the response from the site).
request = urllib2.Request(url, formData, headers)
response = urllib2.urlopen(request)
But when I try to return it in the view
return response
I get the folllowing error
Django Version: 1.3.1
Exception Type: AttributeError
Exception Value: addinfourl instance has no attribute 'has_header'
Exception Location:D:\Python27\lib\site-packages\django\utils\cache.py in patch_vary_headers
note:
I had a csrf error previosly,but i disabled csrf using decorator @csrf_exempt & the error was gone
You shouldn’t return the response from urlopen method directly. Instead your view should return an instance of django’s HttpResponse, where body and the headers should be set to those from the original response: