|
|
|
@ -56,12 +56,21 @@ Future _apiRequest(String method, String path, dynamic data,
|
|
|
|
|
var client = HttpClient();
|
|
|
|
|
HttpClientRequest r;
|
|
|
|
|
if (method == 'POST') {
|
|
|
|
|
r = await client.postUrl(Uri.parse('https://' + serverHost + path));
|
|
|
|
|
r = await client.postUrl(Uri.parse(serverHost + path));
|
|
|
|
|
} else {
|
|
|
|
|
r = await client.getUrl(Uri.parse('https://' + serverHost + path));
|
|
|
|
|
r = await client.getUrl(Uri.parse(serverHost + path));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var strData = '';
|
|
|
|
|
if (data != null) {
|
|
|
|
|
strData = jsonEncode(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (method == 'POST') {
|
|
|
|
|
r.headers.set('Content-Type', 'application/json; charset=utf-8');
|
|
|
|
|
r.headers.set('Content-Length', utf8.encode(strData).length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tokens != null) {
|
|
|
|
|
r.headers.set('Authorization', tokens.accessToken);
|
|
|
|
|
}
|
|
|
|
@ -70,11 +79,9 @@ Future _apiRequest(String method, String path, dynamic data,
|
|
|
|
|
r.headers.set(k, v);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
var strData = '';
|
|
|
|
|
if (data != null) {
|
|
|
|
|
strData = jsonEncode(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r.write(strData);
|
|
|
|
|
|
|
|
|
|
var rp = await r.close();
|
|
|
|
|
var body = await rp.transform(utf8.decoder).join();
|
|
|
|
|
print('${rp.statusCode} - $path');
|
|
|
|
@ -147,12 +154,19 @@ Future _apiRequest(String method, String path, dynamic data,
|
|
|
|
|
var client = HttpClient();
|
|
|
|
|
HttpClientRequest r;
|
|
|
|
|
if (method == 'POST') {
|
|
|
|
|
r = await client.postUrl(Uri.parse('https://' + serverHost + path));
|
|
|
|
|
r = await client.postUrl(Uri.parse(serverHost + path));
|
|
|
|
|
} else {
|
|
|
|
|
r = await client.getUrl(Uri.parse('https://' + serverHost + path));
|
|
|
|
|
r = await client.getUrl(Uri.parse(serverHost + path));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var strData = '';
|
|
|
|
|
if (data != null) {
|
|
|
|
|
strData = jsonEncode(data);
|
|
|
|
|
}
|
|
|
|
|
if (method == 'POST') {
|
|
|
|
|
r.headers.set('Content-Type', 'application/json; charset=utf-8');
|
|
|
|
|
r.headers.set('Content-Length', utf8.encode(strData).length);
|
|
|
|
|
}
|
|
|
|
|
if (tokens != null) {
|
|
|
|
|
r.headers.set('Authorization', tokens.accessToken);
|
|
|
|
|
}
|
|
|
|
@ -161,10 +175,7 @@ Future _apiRequest(String method, String path, dynamic data,
|
|
|
|
|
r.headers.set(k, v);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
var strData = '';
|
|
|
|
|
if (data != null) {
|
|
|
|
|
strData = jsonEncode(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r.write(strData);
|
|
|
|
|
var rp = await r.close();
|
|
|
|
|
var body = await rp.transform(utf8.decoder).join();
|
|
|
|
|