Skip to content

Instantly share code, notes, and snippets.

@Sandyroy95
Created September 6, 2016 18:42
Show Gist options
  • Save Sandyroy95/0f07ce0bae121c238b4e7fc28cf67341 to your computer and use it in GitHub Desktop.
Save Sandyroy95/0f07ce0bae121c238b4e7fc28cf67341 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 …
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")
*************************************************************************
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment