Re: 403 forbidden error

2014-10-27 Thread Diya Rai
On Monday, October 27, 2014 11:05:04 AM UTC+5:30, Chris Angelico wrote:
 On Mon, Oct 27, 2014 at 4:12 PM, Diya Rai diyar...@gmail.com wrote:
  This is the part of the code which im trying to execute. We are trying to 
  load test a web application through python script, currently checking the 
  login part.
 
 
 Does it work when you log in using a web browser? If so, grab a
 browser with debugging facilities (Firefox with Firebug, or Chrome
 with its F12 box, or something), do the login, and have a look at
 exactly what request headers are being sent. Then compare with what
 your script is doing. Once you have the two side by side, you can
 progressively work through it until you figure out which header makes
 the difference - maybe your script isn't sending Host, or maybe you
 need a cookie from a previous request, or maybe it's actually checking
 the Referer and rejecting if it isn't right. Could be all sorts of
 things.
 
 Good luck! Might be a tedious job, or might be the first thing you try.
 
 ChrisA

Thanks a lot ChrisA
It works fine while logging in through browser.
Im using firefox, and have checked the headers with firebug.
I tried passing all the headers and it works while passing the cookie header.
My question is whether is it the correct way to try or can i write python 
script in such a way that it can handle it automatically.
Currently for checking login page, it would be fine.But when we go for testing 
registration page it become tedious.

I would also like to get your opinion on load testing with python script.

Thanks in advance,
Diya

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 403 forbidden error

2014-10-26 Thread Diya Rai
On Wednesday, October 22, 2014 5:07:00 PM UTC+5:30, Diya Rai wrote:
 Hai,
 
   Could anyone please help me to resolve 403 forbidden error while logging 
 into an application.
 
 Following is the error details:
 
 Traceback (most recent call last):
   File ./example6.py, line 18, in module
 response = urllib2.urlopen(req)
   File /usr/lib/python2.7/urllib2.py, line 126, in urlopen
 return _opener.open(url, data, timeout)
   File /usr/lib/python2.7/urllib2.py, line 406, in open
 response = meth(req, response)
   File /usr/lib/python2.7/urllib2.py, line 519, in http_response
 'http', request, response, code, msg, hdrs)
   File /usr/lib/python2.7/urllib2.py, line 444, in error
 return self._call_chain(*args)
   File /usr/lib/python2.7/urllib2.py, line 378, in _call_chain
 result = func(*args)
   File /usr/lib/python2.7/urllib2.py, line 527, in http_error_default
 raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
 urllib2.HTTPError: HTTP Error 403: FORBIDDEN
 
 
 Sorry if the question is not relevant as im new to python.
 
 
 Regards,
 Diya

Thanks Chris Angelico and Dennis Lee Bieber for replying.
Username and password is correct.
Its a simple login script.

import urllib
import httplib2

http = httplib2.Http()

url = 'http://localhost/login_ajax'   
body = {'email': 'x...@google.com', 
'password': '***'}
headers = {'Content-type': 'application/x-www-form-urlencoded'}
response, content = http.request(url, 'POST', headers=headers, 
body=urllib.urlencode(body))
print response

This is the part of the code which im trying to execute. We are trying to load 
test a web application through python script, currently checking the login part.

Thanks in advance,
Diya
-- 
https://mail.python.org/mailman/listinfo/python-list