update RSHttp

This commit is contained in:
2024-02-07 19:32:36 +08:00
parent 7e1352c0be
commit 5fa62351f2
19 changed files with 1202 additions and 169 deletions

View File

@ -0,0 +1,29 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:starcitizen_doctor/common/rust/api/http_api.dart' as rust_http;
import 'package:starcitizen_doctor/common/rust/api/http_api.dart';
class RSHttp {
static Future<String> getText(String url,
{Map<String, String>? headers}) async {
final r = await rust_http.fetch(
method: MyMethod.gets, url: url, headers: headers);
if (r.data == null) return "";
final str = utf8.decode(r.data!);
return str;
}
static Future postData(String url,
{Map<String, String>? headers,
String? contentType,
Uint8List? data}) async {
if (contentType != null) {
headers ??= {};
headers["Content-Type"] = contentType;
}
final r = await rust_http.fetch(
method: MyMethod.post, url: url, headers: headers, inputData: data);
return r.statusCode == 200;
}
}