mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-04-12 11:33:26 +08:00
19 lines
496 B
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";
|
|
}
|