feat: add a hub for the client's own pages and gate mews:do action links
This commit is contained in:
parent
df705d831f
commit
b311b9f7dd
21 changed files with 966 additions and 404 deletions
|
|
@ -151,15 +151,21 @@ class FetchHandler with Handler<FetchCommand, FetchResult> {
|
|||
|
||||
Future<FetchResult> _submitForm(String url, String method, Map<String, String> fields) async {
|
||||
final headers = {'User-Agent': _userAgent};
|
||||
http.Response response;
|
||||
if (method == 'post') {
|
||||
response = await _client
|
||||
.post(Uri.parse(url), headers: headers, body: fields)
|
||||
.timeout(const Duration(seconds: 20));
|
||||
} else {
|
||||
response = await _client
|
||||
.get(Uri.parse(url).replace(queryParameters: fields), headers: headers)
|
||||
.timeout(const Duration(seconds: 20));
|
||||
final http.Response response;
|
||||
try {
|
||||
if (method == 'post') {
|
||||
response = await _client
|
||||
.post(Uri.parse(url), headers: headers, body: fields)
|
||||
.timeout(const Duration(seconds: 20));
|
||||
} else {
|
||||
response = await _client
|
||||
.get(Uri.parse(url).replace(queryParameters: fields), headers: headers)
|
||||
.timeout(const Duration(seconds: 20));
|
||||
}
|
||||
} catch (_) {
|
||||
// A refused connection, a timeout or an address the client cannot speak
|
||||
// are all one failed submit to the reader.
|
||||
return const FetchNetworkError();
|
||||
}
|
||||
if (response.statusCode != 200) return FetchHttpStatusError(response.statusCode);
|
||||
return _parse(response.body, url);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue