Making a HTTP call outside the Thread class/SSL issues

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Making a HTTP call outside the Thread class/SSL issues

Hello fellow Grinders!

In Jython, some of you may know that we cannot make an HTTP call using Grinder's HTTPRequest module outside of the TestRunner class. Now this was annoying. But then I figured that we can't use the HTTPRequest module, but what stops us from using urllib2? 
So, I imported urllib2 and tried making the call outside of the Testrunner class. It works according to me, but I'm not able to get a reply because I'm getting an SSL exception. Mainly because I'm trying to make a urlopen call to an HTTPS url. On reading up solutions online, I read that you could import the ssl library and skip the check like below

import urllib2
import ssl

ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

urllib2.urlopen("https://your-test-server.local", context=ctx)
However, when I try the import ssl in Grinder, it says the module cannot be found. ssl comes by default with Jython, does it not? 

So, friends, my question is, do I just manually add the file into my Grinder or does anyone have a better workaround or my base problem?

P.S - I know skipping this check may be dangerous but I'm using it within my organization only, so I think it's alright.

Many thanks in advance!
Rohit Nambiar

Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.
grinder-use mailing list
[hidden email]