(self, testcase_dict, entry_json)
parse HAR entry request data, and make testcase request data
parse HAR entry request data, and make testcase request data
parse HAR entry request data and make testcase request data
def _make_har_request_data(self, testcase_dict, entry_json):
        """ parse HAR entry request data, and make testcase request data
        """
        method = entry_json["request"].get("method")
        if not method:
            logging.exception("method missed in request.")
            sys.exit(1)

        testcase_dict["method"] = method
        if method in ["POST", "PUT"]:
            mimeType = entry_json["request"].get("postData", {}).get("mimeType")

            # Note that text and params fields are mutually exclusive.
            params = entry_json["request"].get("postData", {}).get("params", [])
            text = entry_json["request"].get("postData", {}).get("text")
            if text:
                post_data = text
            else:
                post_data = convert_list_to_dict(params)

            request_data_key = "data"
            if not mimeType:
                pass
            elif mimeType.startswith("application/json"):
                post_data = json.loads(post_data)
                request_data_key = "json"
            elif mimeType.startswith("application/x-www-form-urlencoded"):
                # post_data = utils.x_www_form_urlencoded(post_data)
                pass
            else:
                # TODO: make compatible with more mimeType
                pass
            testcase_dict["variable_type"] = request_data_key
            if request_data_key == 'json':
                testcase_dict["json_variable"] = json.dumps(post_data)
            else:
                testcase_dict["variable"] = json.dumps([
                    {'key': k, 'value': v, 'param_type': 'string'} for k, v in post_data.items()])
def _make_har_request_data ( self , testcase_dict , entry_json ) : method = entry_json [ "request" ] . get ( "method" ) if not method : logging . exception ( "method missed in request." ) sys . exit ( 1 ) testcase_dict [ "method" ] = method if method in [ "POST" , "PUT" ] : mimeType = entry_json [ "request" ] . get ( "postData" , { } ) . get ( "mimeType" ) # Note that text and params fields are mutually exclusive. params = entry_json [ "request" ] . get ( "postData" , { } ) . get ( "params" , [ ] ) text = entry_json [ "request" ] . get ( "postData" , { } ) . get ( "text" ) if text : post_data = text else : post_data = convert_list_to_dict ( params ) request_data_key = "data" if not mimeType : pass elif mimeType . startswith ( "application/json" ) : post_data = json . loads ( post_data ) request_data_key = "json" elif mimeType . startswith ( "application/x-www-form-urlencoded" ) : # post_data = utils.x_www_form_urlencoded(post_data) pass else : # TODO: make compatible with more mimeType pass testcase_dict [ "variable_type" ] = request_data_key if request_data_key == 'json' : testcase_dict [ "json_variable" ] = json . dumps ( post_data ) else : testcase_dict [ "variable" ] = json . dumps ( [ { 'key' : k , 'value' : v , 'param_type' : 'string' } for k , v in post_data . items ( ) ] )