Skip to content

Commit

Permalink
Merge pull request #1259 from locustio/add-json()-method-to-fasthttpl…
Browse files Browse the repository at this point in the history
…ocust-client-to-support-the-same-things-as-regular-httplocust

add json() method to FastHttpLocust (to match regular HttpLocust)
  • Loading branch information
cyberw authored Feb 20, 2020
2 parents 36f8ca3 + e2ba0dd commit 1165ca8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions locust/contrib/fasthttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import re
import socket
import json
from base64 import b64encode
from urllib.parse import urlparse, urlunparse
from ssl import SSLError
Expand Down Expand Up @@ -254,6 +255,9 @@ def text(self):
self.encoding = self.headers.get('content-type', '').partition("charset=")[2] or 'utf-8'
return str(self.content, self.encoding, errors='replace')

def json(self):
return json.loads(self.text)

def raise_for_status(self):
"""Raise any connection errors that occured during the request"""
if hasattr(self, 'error') and self.error:
Expand Down

0 comments on commit 1165ca8

Please sign in to comment.