|
|
|
|
@ -68,16 +68,11 @@ public class Connect { |
|
|
|
|
if (req.getData() != null && "json".equals(req.getPostType())) return getJsonBody(req); |
|
|
|
|
if (req.getData() != null && "form".equals(req.getPostType())) return getFormBody(req); |
|
|
|
|
if (req.getData() != null && "form-data".equals(req.getPostType())) return getFormDataBody(req); |
|
|
|
|
if (req.getData() != null && "raw".equals(req.getPostType())) return getRawBody(req); |
|
|
|
|
if (req.getBody() != null && contentType != null) return RequestBody.create(req.getBody(), MediaType.get(contentType)); |
|
|
|
|
return RequestBody.create("", null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static RequestBody getJsonBody(Req req) { |
|
|
|
|
return RequestBody.create(req.getData().toString(), MediaType.get("application/json")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static RequestBody getRawBody(Req req) { |
|
|
|
|
return RequestBody.create(req.getData().toString(), MediaType.get("application/json; charset=utf-8")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -96,8 +91,6 @@ public class Connect { |
|
|
|
|
return builder.build(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void setHeader(QuickJSContext ctx, Response res, JSObject object) { |
|
|
|
|
for (Map.Entry<String, List<String>> entry : res.headers().toMultimap().entrySet()) { |
|
|
|
|
if (entry.getValue().size() == 1) object.setProperty(entry.getKey(), entry.getValue().get(0)); |
|
|
|
|
|