mirror of
https://github.com/foss42/apidash.git
synced 2025-08-05 21:10:33 +08:00
Request Body to String? from dynamic
This commit is contained in:
@ -116,14 +116,13 @@ import 'dart:convert';
|
||||
}
|
||||
|
||||
var method = requestModel.method;
|
||||
if (kMethodsWithBody.contains(method) &&
|
||||
requestModel.requestBody != null) {
|
||||
var contentLength = utf8.encode(requestModel.requestBody).length;
|
||||
var requestBody = requestModel.requestBody;
|
||||
if (kMethodsWithBody.contains(method) && requestBody != null) {
|
||||
var contentLength = utf8.encode(requestBody).length;
|
||||
if (contentLength > 0) {
|
||||
hasBody = true;
|
||||
var body = requestModel.requestBody;
|
||||
var templateBody = jj.Template(kTemplateBody);
|
||||
result += templateBody.render({"body": body});
|
||||
result += templateBody.render({"body": requestBody});
|
||||
result = kBodyImportDartConvert + result;
|
||||
result += kBodyLength;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class CollectionStateNotifier extends StateNotifier<List<RequestModel>> {
|
||||
List<KVRow>? requestHeaders,
|
||||
List<KVRow>? requestParams,
|
||||
ContentType? requestBodyContentType,
|
||||
dynamic requestBody,
|
||||
String? requestBody,
|
||||
int? responseStatus,
|
||||
String? message,
|
||||
ResponseModel? responseModel,
|
||||
|
@ -14,15 +14,14 @@ Future<(http.Response?, Duration?, String?)> request(RequestModel requestModel)
|
||||
Map<String, String> headers = rowsToMap(requestModel.requestHeaders) ?? {};
|
||||
http.Response response;
|
||||
String? body;
|
||||
try {
|
||||
if(kMethodsWithBody.contains(requestModel.method)){
|
||||
if(requestModel.requestBody != null){
|
||||
var contentLength = utf8.encode(requestModel.requestBody).length;
|
||||
if (contentLength > 0){
|
||||
body = requestModel.requestBody as String;
|
||||
headers[HttpHeaders.contentLengthHeader] = contentLength.toString();
|
||||
headers[HttpHeaders.contentTypeHeader] = kContentTypeMap[requestModel.requestBodyContentType] ?? "";
|
||||
}
|
||||
try {
|
||||
var requestBody = requestModel.requestBody;
|
||||
if(kMethodsWithBody.contains(requestModel.method) && requestBody != null){
|
||||
var contentLength = utf8.encode(requestBody).length;
|
||||
if (contentLength > 0){
|
||||
body = requestBody;
|
||||
headers[HttpHeaders.contentLengthHeader] = contentLength.toString();
|
||||
headers[HttpHeaders.contentTypeHeader] = kContentTypeMap[requestModel.requestBodyContentType] ?? "";
|
||||
}
|
||||
}
|
||||
Stopwatch stopwatch = Stopwatch()..start();
|
||||
|
Reference in New Issue
Block a user