question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Post requests not functioning properly

See original GitHub issue

Description of issue

Locust v0.11.0 appears to be using GET requests even though locust file specifies to use a post request

Expected behavior

Post request made to specified URI

Actual behavior

Get request is made instead

Environment settings

  • OS: Debian devirative
  • Python version: 3.6.8
  • Locust version: 0.11.0

Steps to reproduce (for bug reports)

#!/usr/bin/env python3
import json

from locust import HttpLocust, TaskSet, task

headers = {
    "Host": "host.host.net",
    "User-Agent":
    "Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0",
    "Accept": "application/json, text/plain, */*",
    "Accept-Language": "en-US,en;q=0.5",
    "Accept-Encoding": "gzip, deflate, br",
    "Content-Type": "application/json;charset=utf-8",
    "Authorization":
    "REDACTED",                                                        
    "refreshTokenId": "REDACTED",
    "Content-Length": "49",
    "Connection": "keep-alive",
}
data = {"UserID": "REDACTED"}


def info(l):
    response = l.client.post("/api/",
                             data=data,
                             headers=headers)
    print(response)
    print(response.text)
    print(response.status_code)


class UserBehavior(TaskSet):
    tasks = {info: 1}


class MyLocust(HttpLocust):
    task_set = UserBehavior
    min_wait = 5000
    max_wait = 15000

Sample of the logs

[2019-06-18 16:09:07,290] Eris/INFO/locust.runners: All locusts hatched: MyLocust: 5
[2019-06-18 16:09:07,303] Eris/INFO/stdout: <Response [405]>
[2019-06-18 16:09:07,304] Eris/INFO/stdout:
[2019-06-18 16:09:07,304] Eris/INFO/stdout: {"message":"The requested resource does not support http method 'GET'."}                                                                        
[2019-06-18 16:09:07,304] Eris/INFO/stdout:
[2019-06-18 16:09:07,304] Eris/INFO/stdout: 405
[2019-06-18 16:09:07,304] Eris/INFO/stdout:
[2019-06-18 16:09:15,109] Eris/ERROR/stderr: KeyboardInterrupt
[2019-06-18 16:09:15,110] Eris/ERROR/stderr: 2019-06-18T20:09:15Z
[2019-06-18 16:09:15,110] Eris/ERROR/stderr:
[2019-06-18 16:09:15,110] Eris/INFO/locust.main: Shutting down (exit code 0), bye.
[2019-06-18 16:09:15,110] Eris/INFO/locust.main: Cleaning up runner...
[2019-06-18 16:09:15,127] Eris/INFO/locust.main: Running teardowns...

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
richkettlecommented, Jan 6, 2021

So the server was issuing a redirect. It was only at the apache level. It was a http vs https issue.

Confusing things further was CURL. It doesn’t change the verb to GET but continues to use POST. Postman on the other hand does what locust does and moves to GET if POST gets redirected.

I’ve read up on it a little and it the different behaviours among different tech is frustrating and there are good points for both. Hopefully this comment is found and helps someone else.

Im unsure on whether locust should log a GET or a POST. It feels like it should do… something.

Right now it logs a POST even if it ends up performing a GET.

1reaction
vcolanoKHcommented, Jul 20, 2022

In case it’s not clear from @richkettle’s comment, if you are encountering this issue try switching your target url from using http to using https. This worked in my case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django POST request not working correctly - Stack Overflow
The problem with this is the POST request is sent when run, but the data is not saved to the database and I...
Read more >
Django POST request not working correctly. - Reddit
Django POST request not working correctly. I'm having a problem related to a Django project I'm working on where I have a simple...
Read more >
POST request not properly authenticated error? (Get Request ...
I'm trying to figure out why I get an error saying “This request is not properly authenticated” when trying out the following command?...
Read more >
POST request not working in Power BI (but working
Hello, I subscribe to data feeds from a vendor that I have to integrate into Power BI but they use POST (not GET)...
Read more >
WSGIDaemonProcess — mod_wsgi 4.9.4 documentation
In general such deadlock problems would not arise with well behaved WSGI applications, but some spam bots attempting to post data to web...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found