mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-16 00:11:28 +03:00
fix: add Content-Length header for empty body POST requests (#13940)
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -202,6 +202,7 @@ class AbModel {
|
|||||||
final api = "${await bind.mainGetApiServer()}/api/ab/settings";
|
final api = "${await bind.mainGetApiServer()}/api/ab/settings";
|
||||||
var headers = getHttpHeaders();
|
var headers = getHttpHeaders();
|
||||||
headers['Content-Type'] = "application/json";
|
headers['Content-Type'] = "application/json";
|
||||||
|
_setEmptyBody(headers);
|
||||||
final resp = await http.post(Uri.parse(api), headers: headers);
|
final resp = await http.post(Uri.parse(api), headers: headers);
|
||||||
if (resp.statusCode == 404) {
|
if (resp.statusCode == 404) {
|
||||||
debugPrint("HTTP 404, api server doesn't support shared address book");
|
debugPrint("HTTP 404, api server doesn't support shared address book");
|
||||||
@@ -228,6 +229,7 @@ class AbModel {
|
|||||||
final api = "${await bind.mainGetApiServer()}/api/ab/personal";
|
final api = "${await bind.mainGetApiServer()}/api/ab/personal";
|
||||||
var headers = getHttpHeaders();
|
var headers = getHttpHeaders();
|
||||||
headers['Content-Type'] = "application/json";
|
headers['Content-Type'] = "application/json";
|
||||||
|
_setEmptyBody(headers);
|
||||||
final resp = await http.post(Uri.parse(api), headers: headers);
|
final resp = await http.post(Uri.parse(api), headers: headers);
|
||||||
if (resp.statusCode == 404) {
|
if (resp.statusCode == 404) {
|
||||||
debugPrint("HTTP 404, current api server is legacy mode");
|
debugPrint("HTTP 404, current api server is legacy mode");
|
||||||
@@ -269,6 +271,7 @@ class AbModel {
|
|||||||
});
|
});
|
||||||
var headers = getHttpHeaders();
|
var headers = getHttpHeaders();
|
||||||
headers['Content-Type'] = "application/json";
|
headers['Content-Type'] = "application/json";
|
||||||
|
_setEmptyBody(headers);
|
||||||
final resp = await http.post(uri, headers: headers);
|
final resp = await http.post(uri, headers: headers);
|
||||||
Map<String, dynamic> json =
|
Map<String, dynamic> json =
|
||||||
_jsonDecodeRespMap(decode_http_response(resp), resp.statusCode);
|
_jsonDecodeRespMap(decode_http_response(resp), resp.statusCode);
|
||||||
@@ -1406,6 +1409,7 @@ class Ab extends BaseAb {
|
|||||||
});
|
});
|
||||||
var headers = getHttpHeaders();
|
var headers = getHttpHeaders();
|
||||||
headers['Content-Type'] = "application/json";
|
headers['Content-Type'] = "application/json";
|
||||||
|
_setEmptyBody(headers);
|
||||||
final resp = await http.post(uri, headers: headers);
|
final resp = await http.post(uri, headers: headers);
|
||||||
statusCode = resp.statusCode;
|
statusCode = resp.statusCode;
|
||||||
Map<String, dynamic> json =
|
Map<String, dynamic> json =
|
||||||
@@ -1463,6 +1467,7 @@ class Ab extends BaseAb {
|
|||||||
);
|
);
|
||||||
var headers = getHttpHeaders();
|
var headers = getHttpHeaders();
|
||||||
headers['Content-Type'] = "application/json";
|
headers['Content-Type'] = "application/json";
|
||||||
|
_setEmptyBody(headers);
|
||||||
final resp = await http.post(uri, headers: headers);
|
final resp = await http.post(uri, headers: headers);
|
||||||
statusCode = resp.statusCode;
|
statusCode = resp.statusCode;
|
||||||
List<dynamic> json =
|
List<dynamic> json =
|
||||||
@@ -1977,3 +1982,8 @@ String _jsonDecodeActionResp(http.Response resp) {
|
|||||||
}
|
}
|
||||||
return errMsg;
|
return errMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/seanmonstar/reqwest/issues/838
|
||||||
|
void _setEmptyBody(Map<String, String> headers) {
|
||||||
|
headers['Content-Length'] = '0';
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user