Making a HTTP call outside the Thread class/SSL issues

Rohit Nambiar <[email protected]> Wed, 9 Nov 2016 11:04:55 +0530
Newsgroups gmane.comp.java.grinder.user
Message-ID <CAHvE9B+A0hSzSN-ydWkrMFoa8PTUd5OMojce=Ykb_X5HQvJ4vQ@mail.gmail.com>
--===============0838189544891832679==
Content-Type: multipart/alternative; boundary=001a113eacdafaffba0540d79db4

--001a113eacdafaffba0540d79db4
Content-Type: text/plain; charset=UTF-8

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 urllib2import 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 ssl.py 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

--001a113eacdafaffba0540d79db4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello fellow Grinders!<div><br></div><div>In Jython, some =
of you may know that we cannot make an HTTP call using Grinder&#39;s HTTPRe=
quest module outside of the TestRunner class. Now this was annoying. But th=
en I figured that we can&#39;t use the HTTPRequest module, but what stops u=
s from using urllib2?=C2=A0</div><div>So, I imported urllib2 and tried maki=
ng the call outside of the Testrunner class. It works according to me, but =
I&#39;m not able to get a reply because I&#39;m getting an SSL exception. M=
ainly because I&#39;m trying to make a urlopen call to an HTTPS url. On rea=
ding up solutions online, I read that you could import the ssl library and =
skip the check like below</div><div><br></div><div><pre class=3D"gmail-lang=
-py gmail-prettyprint gmail-prettyprinted" style=3D"margin-top:0px;margin-b=
ottom:1em;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px=
;overflow:auto;font-family:consolas,menlo,monaco,&quot;lucida console&quot;=
,&quot;liberation mono&quot;,&quot;dejavu sans mono&quot;,&quot;bitstream v=
era sans mono&quot;,&quot;courier new&quot;,monospace,sans-serif;background=
-color:rgb(239,240,241);color:rgb(57,51,24);word-wrap:normal"><code style=
=3D"margin:0px;padding:0px;border:0px;font-family:consolas,menlo,monaco,&qu=
ot;lucida console&quot;,&quot;liberation mono&quot;,&quot;dejavu sans mono&=
quot;,&quot;bitstream vera sans mono&quot;,&quot;courier new&quot;,monospac=
e,sans-serif;white-space:inherit"><span class=3D"gmail-kwd" style=3D"margin=
:0px;padding:0px;border:0px;color:rgb(16,16,148)">import</span><span class=
=3D"gmail-pln" style=3D"margin:0px;padding:0px;border:0px;color:rgb(48,51,5=
4)"> urllib2
</span><span class=3D"gmail-kwd" style=3D"margin:0px;padding:0px;border:0px=
;color:rgb(16,16,148)">import</span><span class=3D"gmail-pln" style=3D"marg=
in:0px;padding:0px;border:0px;color:rgb(48,51,54)"> ssl

ctx </span><span class=3D"gmail-pun" style=3D"margin:0px;padding:0px;border=
:0px;color:rgb(48,51,54)">=3D</span><span class=3D"gmail-pln" style=3D"marg=
in:0px;padding:0px;border:0px;color:rgb(48,51,54)"> ssl</span><span class=
=3D"gmail-pun" style=3D"margin:0px;padding:0px;border:0px;color:rgb(48,51,5=
4)">.</span><span class=3D"gmail-pln" style=3D"margin:0px;padding:0px;borde=
r:0px;color:rgb(48,51,54)">create_default_context</span><span class=3D"gmai=
l-pun" style=3D"margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">()</=
span><span class=3D"gmail-pln" style=3D"margin:0px;padding:0px;border:0px;c=
olor:rgb(48,51,54)">
ctx</span><span class=3D"gmail-pun" style=3D"margin:0px;padding:0px;border:=
0px;color:rgb(48,51,54)">.</span><span class=3D"gmail-pln" style=3D"margin:=
0px;padding:0px;border:0px;color:rgb(48,51,54)">check_hostname </span><span=
 class=3D"gmail-pun" style=3D"margin:0px;padding:0px;border:0px;color:rgb(4=
8,51,54)">=3D</span><span class=3D"gmail-pln" style=3D"margin:0px;padding:0=
px;border:0px;color:rgb(48,51,54)"> </span><span class=3D"gmail-kwd" style=
=3D"margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">False</span><sp=
an class=3D"gmail-pln" style=3D"margin:0px;padding:0px;border:0px;color:rgb=
(48,51,54)">
ctx</span><span class=3D"gmail-pun" style=3D"margin:0px;padding:0px;border:=
0px;color:rgb(48,51,54)">.</span><span class=3D"gmail-pln" style=3D"margin:=
0px;padding:0px;border:0px;color:rgb(48,51,54)">verify_mode </span><span cl=
ass=3D"gmail-pun" style=3D"margin:0px;padding:0px;border:0px;color:rgb(48,5=
1,54)">=3D</span><span class=3D"gmail-pln" style=3D"margin:0px;padding:0px;=
border:0px;color:rgb(48,51,54)"> ssl</span><span class=3D"gmail-pun" style=
=3D"margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span cl=
ass=3D"gmail-pln" style=3D"margin:0px;padding:0px;border:0px;color:rgb(48,5=
1,54)">CERT_NONE

urllib2</span><span class=3D"gmail-pun" style=3D"margin:0px;padding:0px;bor=
der:0px;color:rgb(48,51,54)">.</span><span class=3D"gmail-pln" style=3D"mar=
gin:0px;padding:0px;border:0px;color:rgb(48,51,54)">urlopen</span><span cla=
ss=3D"gmail-pun" style=3D"margin:0px;padding:0px;border:0px;color:rgb(48,51=
,54)">(</span><span class=3D"gmail-str" style=3D"margin:0px;padding:0px;bor=
der:0px;color:rgb(125,39,39)">&quot;<a href=3D"https://your-test-server.loc=
al">https://your-test-server.local</a>&quot;</span><span class=3D"gmail-pun=
" style=3D"margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">,</span><=
span class=3D"gmail-pln" style=3D"margin:0px;padding:0px;border:0px;color:r=
gb(48,51,54)"> context</span><span class=3D"gmail-pun" style=3D"margin:0px;=
padding:0px;border:0px;color:rgb(48,51,54)">=3D</span><span class=3D"gmail-=
pln" style=3D"margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">ctx</s=
pan><span class=3D"gmail-pun" style=3D"margin:0px;padding:0px;border:0px;co=
lor:rgb(48,51,54)">)</span></code></pre><div>However, when I try the import=
 ssl in Grinder, it says the module cannot be found. ssl comes by default w=
ith Jython, does it not?=C2=A0</div><div><br></div><div>So, friends, my que=
stion is, do I just manually add the ssl.py file into my Grinder or does an=
yone have a better workaround or my base problem?</div><div><br></div><div>=
P.S - I know skipping this check may be dangerous but I&#39;m using it with=
in my organization only, so I think it&#39;s alright.<br></div><div><br></d=
iv><div>Many thanks in advance!</div><div class=3D"gmail_signature"><div di=
r=3D"ltr"><div>Rohit Nambiar</div></div></div>
</div></div>

--001a113eacdafaffba0540d79db4--


--===============0838189544891832679==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
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. http://sdm.link/xeonphi
--===============0838189544891832679==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
grinder-use mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/grinder-use

--===============0838189544891832679==--