Skip to content

Instantly share code, notes, and snippets.

@Sandyroy95
Created September 6, 2016 14:29
Show Gist options
  • Save Sandyroy95/2d6f144c64bb2cb707bd3bbe9ed068e0 to your computer and use it in GitHub Desktop.
Save Sandyroy95/2d6f144c64bb2cb707bd3bbe9ed068e0 to your computer and use it in GitHub Desktop.
Hi everyone,
I am currently working on a project in Locust where I have to perform a simple GET/POST operation through a proxy. I have got the entire script ready.However im having some trouble getting it through a proxy. I have tried a number of traditional python methods such as 'export HTTP_PROXY" or urllib2.ProxyHandler' but it's been of no avail.
I am attaching a segment of my code to show my current approach:
***********************************************************************************
class UserBehavior(TaskSet):
def on_start(self):
self.login()
def login(self):
proxy_support = urllib2.ProxyHandler({"https":"https://xxxxxxxxxxx"})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
urllib2.urlopen("https://yyyyyyyyyyyyyyyyyyy").read()
self.client.post("/persistence/login", {"Username":"Ivan", "Password":"Ivan"})
@task(1)
def profile(self):
self.client.get("/persistence/forum")
***********************************************************************
Please help me as to why am I not able to bypass it through a proxy and suggest any possible changes to my code.
Thanks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment