newLike method

Future<Uint8List> newLike(
  1. String rootShortlink,
  2. Uint8List katamari
)

Implementation

Future<Uint8List> newLike(String rootShortlink, Uint8List katamari) async {
  var url = Uri.parse(uri + '/like/' + rootShortlink + '?bin=true');
  try {
    var response = await http.post(url, body: {
      'katamari': base64Encode(katamari),
    }, headers: {
      'Cookie': 'DARTSESSID=' + dartSessionId
    }).timeout(_timoutIn);
    if (response == null) return Uint8List(0);
    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);
    }

    return response.bodyBytes;
  } catch (e) {
    print('Future<Uint8List> newLike httpconnector ERROR');
    print(e);
    if (!(e is TimeoutException)) setOffline();
    return Uint8List(0);
  }
}