Locust错误:HTTPError(u'405客户端错误:URL:https://..../login')不允许 [英] Locust Error: HttpError (u'405 Client Error: Not Allowed for url: https://..../login')

查看:17
本文介绍了Locust错误:HTTPError(u'405客户端错误:URL:https://..../login')不允许的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对Web服务器进行负载测试,但我使用self.client.verify = False禁用了该站点的SSL证书。

from locust import HttpLocust, TaskSet, task

class UserBehavior(TaskSet):

    def on_start(self):
        self.client.verify = False

    @task(1)
    def options(self):
        self.client.options('//oauth/token')

    @task(2)
    def login(self):
        self.client.post("//oauth/token", {"username":"admin","password":"password","provider":"users","grant_type":"password","client_id":2,"client_secret":"somethinghere","scope":"*"})

class WebsiteUser(HttpLocust):
    task_set = UserBehavior
    min_wait = 5000
    max_wait = 9000
现在有一个错误,内容是:

有人能帮我纠正这个错误吗?谢谢!

推荐答案

您需要将词典转储为字符串

显式:

self.client.post("//oauth/token", json.dumps({"username"...

或隐式使用json参数:

self.client.post("//oauth/token", json={"username"...

(编辑后,一开始我以为问题出在双斜杠上)

这篇关于Locust错误:HTTPError(u'405客户端错误:URL:https://..../login')不允许的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆