diff --git a/locust/test/test_fasthttp.py b/locust/test/test_fasthttp.py index 70f5d37f45..ed5ab9138e 100644 --- a/locust/test/test_fasthttp.py +++ b/locust/test/test_fasthttp.py @@ -423,6 +423,16 @@ class MyUser(FastHttpUser): locust = MyUser(self.environment) self.assertEqual(200, locust.client.head("/request_method").status_code) + def test_complex_content_type(self): + class MyUser(FastHttpUser): + host = "http://127.0.0.1:%i" % self.port + + locust = MyUser(self.environment) + + self.assertEqual("stuff", locust.client.get("/content_type_missing_charset").text) + self.assertEqual("stuff", locust.client.get("/content_type_regular").text) + self.assertEqual("stuff", locust.client.get("/content_type_with_extra_stuff").text) + def test_log_request_name_argument(self): self.response = "" diff --git a/locust/test/testcases.py b/locust/test/testcases.py index 124921f09c..4a4ffc60c1 100644 --- a/locust/test/testcases.py +++ b/locust/test/testcases.py @@ -149,6 +149,27 @@ def rest(): return request.json +@app.route("/content_type_missing_charset") +def content_type_missing_charset(): + resp = make_response("stuff") + resp.headers["Content-Type"] = "Content-Type: application/json;" + return resp + + +@app.route("/content_type_regular") +def content_type_regular(): + resp = make_response("stuff") + resp.headers["Content-Type"] = "Content-Type: application/json; charset=utf-8;" + return resp + + +@app.route("/content_type_with_extra_stuff") +def content_type_with_extra_stuff(): + resp = make_response("stuff") + resp.headers["Content-Type"] = "Content-Type: application/json; charset=utf-8; api-version=3.0" + return resp + + class LocustTestCase(unittest.TestCase): """ Test case class that restores locust.events.EventHook listeners on tearDown, so that it is