Skip to content

Commit 15c38c6

Browse files
committed
removed errors
1 parent 3eb71bb commit 15c38c6

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

lib/codegen/java/async_http_client.dart

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,13 @@ public class Main {
7676

7777
String? getCode(
7878
RequestModel requestModel,
79-
String defaultUriScheme,
8079
) {
8180
try {
8281
String result = "";
8382
bool hasBody = false;
84-
bool hasJsonBody = false;
85-
86-
String url = requestModel.url;
87-
if (!url.contains("://") && url.isNotEmpty) {
88-
url = "$defaultUriScheme://$url";
89-
}
9083

9184
var rec = getValidRequestUri(
92-
url,
85+
requestModel.url,
9386
requestModel.enabledRequestParams,
9487
);
9588
Uri? uri = rec.$1;
@@ -98,7 +91,7 @@ public class Main {
9891
return "";
9992
}
10093

101-
url = stripUriParams(uri);
94+
var url = stripUriParams(uri);
10295

10396
// contains the HTTP method associated with the request
10497
var method = requestModel.method;
@@ -117,20 +110,13 @@ public class Main {
117110
// if request type is not form data, the request method can include
118111
// a body, and the body of the request is not null, in that case
119112
// we need to parse the body as it is, and write it to the body
120-
if (!requestModel.isFormDataRequest &&
113+
if (!requestModel.hasFormData &&
121114
kMethodsWithBody.contains(method) &&
122115
requestBody != null) {
123116
var contentLength = utf8.encode(requestBody).length;
124117
if (contentLength > 0) {
125118
var templateBodyContent = jj.Template(kTemplateRequestBodyContent);
126119
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-
134120
if (harJson["postData"]?["text"] != null) {
135121
result += templateBodyContent.render({
136122
"body": kEncoder.convert(harJson["postData"]["text"]).substring(
@@ -174,7 +160,7 @@ public class Main {
174160
});
175161

176162
// handling form data
177-
if (requestModel.isFormDataRequest &&
163+
if (requestModel.hasFormData &&
178164
requestModel.formDataMapList.isNotEmpty &&
179165
kMethodsWithBody.contains(method)) {
180166
// including form data into the request

0 commit comments

Comments
 (0)