diff --git a/src/RequestsLibrary/RequestsKeywords.py b/src/RequestsLibrary/RequestsKeywords.py index fff0e77a..d283aef1 100644 --- a/src/RequestsLibrary/RequestsKeywords.py +++ b/src/RequestsLibrary/RequestsKeywords.py @@ -921,7 +921,6 @@ def request_should_be_successful(self, response): """ self._check_status(None, response, msg=None) - def _common_request( self, method, @@ -1026,7 +1025,7 @@ def _format_data_according_to_header(self, session, data, headers): # Merged headers are already case insensitive headers = utils.merge_headers(session, headers) - if data is not None and headers is not None and 'Content-Type' in headers and not self._is_json(data): + if data is not None and headers is not None and 'Content-Type' in headers and not utils.is_json(data): if headers['Content-Type'].find("application/json") != -1: if not isinstance(data, types.GeneratorType): if str(data).strip(): @@ -1096,14 +1095,6 @@ def _log_response(method, response): response.text) - @staticmethod - def _is_json(data): - try: - json.loads(data) - except (TypeError, ValueError): - return False - return True - @staticmethod def _is_string_type(data): if PY3 and isinstance(data, str): diff --git a/src/RequestsLibrary/utils.py b/src/RequestsLibrary/utils.py index 359038b2..fae6c00a 100644 --- a/src/RequestsLibrary/utils.py +++ b/src/RequestsLibrary/utils.py @@ -35,6 +35,14 @@ def merge_headers(session, headers): return merged_headers +def is_json(data): + try: + json.loads(data) + except (TypeError, ValueError): + return False + return True + + def json_pretty_print(content): """ Pretty print a JSON object