@@ -76,20 +76,13 @@ public class Main {
76
76
77
77
String ? getCode (
78
78
RequestModel requestModel,
79
- String defaultUriScheme,
80
79
) {
81
80
try {
82
81
String result = "" ;
83
82
bool hasBody = false ;
84
- bool hasJsonBody = false ;
85
-
86
- String url = requestModel.url;
87
- if (! url.contains ("://" ) && url.isNotEmpty) {
88
- url = "$defaultUriScheme ://$url " ;
89
- }
90
83
91
84
var rec = getValidRequestUri (
92
- url,
85
+ requestModel. url,
93
86
requestModel.enabledRequestParams,
94
87
);
95
88
Uri ? uri = rec.$1;
@@ -98,7 +91,7 @@ public class Main {
98
91
return "" ;
99
92
}
100
93
101
- url = stripUriParams (uri);
94
+ var url = stripUriParams (uri);
102
95
103
96
// contains the HTTP method associated with the request
104
97
var method = requestModel.method;
@@ -117,20 +110,13 @@ public class Main {
117
110
// if request type is not form data, the request method can include
118
111
// a body, and the body of the request is not null, in that case
119
112
// we need to parse the body as it is, and write it to the body
120
- if (! requestModel.isFormDataRequest &&
113
+ if (! requestModel.hasFormData &&
121
114
kMethodsWithBody.contains (method) &&
122
115
requestBody != null ) {
123
116
var contentLength = utf8.encode (requestBody).length;
124
117
if (contentLength > 0 ) {
125
118
var templateBodyContent = jj.Template (kTemplateRequestBodyContent);
126
119
hasBody = true ;
127
-
128
- // every JSON should be enclosed within a pair of curly braces
129
- // very simple check for JSON, for stronger check, we may validate
130
- // the JSON in the JSON editor itself
131
- hasJsonBody =
132
- requestBody.startsWith ("{" ) && requestBody.endsWith ("}" );
133
-
134
120
if (harJson["postData" ]? ["text" ] != null ) {
135
121
result += templateBodyContent.render ({
136
122
"body" : kEncoder.convert (harJson["postData" ]["text" ]).substring (
@@ -174,7 +160,7 @@ public class Main {
174
160
});
175
161
176
162
// handling form data
177
- if (requestModel.isFormDataRequest &&
163
+ if (requestModel.hasFormData &&
178
164
requestModel.formDataMapList.isNotEmpty &&
179
165
kMethodsWithBody.contains (method)) {
180
166
// including form data into the request
0 commit comments