Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6755009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:20:57+00:00 2026-05-26T13:20:57+00:00

This is what I want. Submit a POST request to a external site(i.e login

  • 0

This is what I want.

  1. Submit a POST request to a external site(i.e login information).
  2. Receive the response
  3. Return the raw response to my client’s browser(containing the cookies for login
    validation).
  4. 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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:20:58+00:00Added an answer on May 26, 2026 at 1:20 pm

    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:

    from django.http import HttpResponse
    import urllib2
    
    def my_view(request):
        request = urllib2.Request(url, formData, headers)
        response = urllib2.urlopen(request)
    
        # set the body
        r = HttpResponse(response.read())
    
        # set the headers
        for header in response.info().keys():
            r[header] = response.info()[header]
    
        return r
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a post request and i do like this: function Xxx_Click()
I want to receive multi file post from image uploader.( i use this )
I want to submit a form like this: <input type=button onclick=$('#form1').submit(); value=Create /> but
the code below is a jquery POST request javascript. i want to use the
I want to fake a page submit (post) on clicking a link. I need
I want to spit out everything in Request.Form so I can just return it
I want to make a POST to a PHP site from a C# WinForm
i am trying this python script: import httplib import urllib conn = httplib.HTTPConnection(moodle.tau.ac.il) conn.request(POST
In my ASP.NET application, I want to make a POST request out to a
I want to validate user entries on a WordPress post upon hitting the submit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.