newReply method
Implementation
Future<Uint8List> newReply(
String _baseUri,
String text,
String rootShortlink,
String ppShortlink,
Uint8List katamari,
String nick,
String avatar,
Uint8List attachment) async {
var url = Uri.parse(_baseUri + '/reply/' + rootShortlink + '?bin=true');
print('replyThreadThread:' + text);
try {
var response = await http.post(
url,
body: {
'reply': text,
'katamari': base64Encode(katamari),
'nick': nick,
'avatar': avatar,
'pp': ppShortlink,
'attachment': base64Encode(attachment)
},
headers: {'Cookie': 'DARTSESSID=' + dartSessionId},
).timeout(_timoutIn);
if (response == null) return Uint8List(0);
setOnline();
if (response.statusCode == 409) {
//dup
return Uint8List(1);
}
if (response.statusCode == 502) {
//dup
return Uint8List(2);
}
if (response.statusCode != 200) return Uint8List(0);
print('Response status: ${response.statusCode}');
String? h = response.headers["set-cookie"];
if (h != null) {
cookie = h.split(' ').first;
String dSid = cookie.split('=').last;
dartSessionId = dSid.substring(0, dSid.length - 1);
}
print(cookie);
print(response.contentLength);
return response.bodyBytes;
} catch (e) {
print('Future<Uint8List> newReply httpconnector ERROR');
if (!(e is TimeoutException)) setOffline();
print(e);
return Uint8List(0);
}
}