Files
proxypin/lib/utils/curl.dart

19 lines
496 B
Dart

import 'package:network_proxy/network/http/http.dart';
///复制cURL请求
String curlRequest(HttpRequest request) {
List<String> headers = [];
request.headers.forEach((key, values) {
for (var val in values) {
headers.add(" -H '$key: $val' ");
}
});
String body = '';
if (request.bodyAsString.isNotEmpty) {
body = " --data '${request.bodyAsString}' \\\n";
}
return "curl '${request.requestUrl}' \\\n"
"${headers.join('\\\n')} $body \\\n --compressed";
}