isoos / http_client

https://pub.dartlang.org/packages/http_client
BSD 3-Clause "New" or "Revised" License
13 stars 6 forks source link

Permission denied on android #11

Closed alr2413 closed 3 years ago

alr2413 commented 3 years ago

i tried the following simple code on a real android 10 device, but it throws permission denied:

ElevatedButton(
            onPressed: () async {
              httpClient = CurlClient();
              var request = http.Request('get', 'http://google.com');
              var response = await httpClient.send(request);
              print(response.statusCode);
              httpClient.close();
            },
            child: Text('Test'),
          ),
E/flutter ( 3833): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: ProcessException: Permission denied
E/flutter ( 3833):   Command: curl -L -X GET http://google.com
E/flutter ( 3833): #0      _ProcessImpl._start (dart:io-patch/process_patch.dart:390:33)
E/flutter ( 3833): #1      Process.start (dart:io-patch/process_patch.dart:36:20)
E/flutter ( 3833): #2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:565:18)
E/flutter ( 3833): #3      Process.run (dart:io-patch/process_patch.dart:47:12)
E/flutter ( 3833): #4      CurlClient.send (package:http_client/curl.dart:91:23)
isoos commented 3 years ago

You may need to enable network permissions: https://flutter.dev/docs/development/data-and-backend/networking#android

alr2413 commented 3 years ago

i already did that.

isoos commented 3 years ago

Oh... you are using the curl-based client. Why do you need to use that in a Flutter app?

alr2413 commented 3 years ago

to create a socks proxy app. is that possible? Do i need to add a curl repo to my android build.gradle file?

isoos commented 3 years ago

to create a socks proxy app. is that possible?

This curl client was developed for a specific server app that requested HTTP via curl infrequently. I don't think it would be great to execute curl on each request, and it wouldn't be a proxy.

Maybe this package would help you? https://pub.dev/packages/socks5

alr2413 commented 3 years ago

Ok. Thanks.