0

I am having an issue with python-requests and doing some searching I have not been able to find a solution. I have a web handler that accepts a few parameters which include the username and password. When requests goes to make the request.

self._get_query() returns {'username': 'test', 'password', 'test', 'check', 'True'}
r = requests.get(self._site, params=self._get_query())
r.text = "No username or password provided"

Doing some inspection on on run I see that my username and password parameters are being excluded from the dict.

r.url = r'http://localhost/test.ashx?check=True'

I'm not sure why this is happening?

P.S. The site does not use basic authentication or anything where requests.get(auth=<something>) would help. The username and password parameter is passed to the ashx for a back-end login.

fejese
  • 4,601
  • 4
  • 29
  • 36
thedemon
  • 329
  • 1
  • 6
  • 19
  • Is there anything in `r.history`? – Ian Stapleton Cordasco Jun 10 '14 at 15:04
  • @sigmavirus24 - Yes, I get two response 302 objects back from `r.history` and looking at the `r.history[0].url` it shows the username and password in the query. So I guess my issue is with the webserver? The text returned from the objects states `` in the html... – thedemon Jun 10 '14 at 15:19
  • 1
    yes, the issue is indeed with the webserver. – Ian Stapleton Cordasco Jun 10 '14 at 16:52
  • Also you should check `r.headers['Location']` on the header from that 302 response. It should be the url that you're seeing without the user/password parameters. – Ian Stapleton Cordasco Jun 10 '14 at 20:37
  • Yup looking in `r.headers['Location']` I can see where the web handler is doing a redirect to the login page (though it is not suppose to do that since the credentials are supplied) I can see what exactly is going on. Thank you for the assistance. **Reference:** [Response Redirect From ASHX File](http://stackoverflow.com/questions/2048974/response-redirect-from-ashx-file) – thedemon Jun 10 '14 at 21:17

0 Answers0