go-vikunja / app

MIT License
270 stars 23 forks source link

Switch Back to package:http #15

Closed k9withabone closed 2 years ago

k9withabone commented 2 years ago

6f43c9357d1b5c96c39e7b0ee8f2a8a0038569ed introduced a bug where if multiple HTTP requests were made quickly then the requests would get garbled.

I propose switching back to using package:http and using HttpOverrides instead. Something like:

class IgnoreCertHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext? context) {
    return super.createHttpClient(context)
      ..badCertificateCallback = (_, __, ___) => ignoreCertificates;
  }
}

Then either set the global overrides: HttpOverrides.global = IgnoreCertHttpOverrides(), or use:

HttpOverrides.runWithHttpOverrides(() {
  // request
}, IgnoreCertHttpOverrides());

Another option is to use the dio package like so:

(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate  = (client) {
  client.badCertificateCallback=(_, __, ___) => ignoreCertificates;
};

as documented here.

Benimautner commented 2 years ago

You were right, the switch to HttpClient was made with bad judgement and too prematurely. I just implemented what you proposed, however I still have no way of testing whether the certificate ignoring actually works. Regardless, attached to this issue you will find a compiled app. As far as I can tell, it works better than with HttpClient, however, I have not had the time to test it.

app-main-release.zip

Benimautner commented 2 years ago

realized in v0.0.20-alpha