Skip to content

Instantly share code, notes, and snippets.

@jamesdixon
Last active July 6, 2020 14:21
Show Gist options
  • Save jamesdixon/c9a807f607066bb4b19ad51416d72ba2 to your computer and use it in GitHub Desktop.
Save jamesdixon/c9a807f607066bb4b19ad51416d72ba2 to your computer and use it in GitHub Desktop.

Revisions

  1. jamesdixon revised this gist Oct 6, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dio-proxy.dart
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ Dio dio = Dio();
    (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
    // Hook into the findProxy callback to set the client's proxy.
    client.findProxy = (url) {
    return 'PROXY $proxy'?;
    return 'PROXY $proxy';
    };

    // This is a workaround to allow Charles to receive
  2. jamesdixon revised this gist Sep 4, 2019. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions dio-proxy.dart
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,20 @@
    // make sure to replace <YOUR_LOCAL_IP> with
    // the external IP of your computer.
    String proxy = '<YOUR_LOCAL_IP>:8888';
    // Make sure to replace <YOUR_LOCAL_IP> with
    // the external IP of your computer if you're using Android.
    // Note that we're using port 8888 which is Charles' default.
    String proxy = Platform.isAndroid ? '<YOUR_LOCAL_IP>:8888' : 'localhost:8888';

    // create a new Dio instance
    // Create a new Dio instance.
    Dio dio = Dio();

    // tap into the onHttpClientCreate callback
    // to configure the proxy just as we did earlier
    (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
    // hook into the findProxy callback to set
    // the client's proxy
    // Tap into the onHttpClientCreate callback
    // to configure the proxy just as we did earlier.
    (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
    // Hook into the findProxy callback to set the client's proxy.
    client.findProxy = (url) {
    return 'PROXY $proxy'?;
    };

    // this is a workaround to allow Charles to receive
    // SSL payloads when your app is running on Android
    // This is a workaround to allow Charles to receive
    // SSL payloads when your app is running on Android.
    client.badCertificateCallback = (X509Certificate cert, String host, int port) => Platform.isAndroid;
    }
  3. jamesdixon revised this gist Aug 30, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions dio-proxy.dart
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ Dio dio = Dio();

    // tap into the onHttpClientCreate callback
    // to configure the proxy just as we did earlier
    (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) client.badCertificateCallback =
    (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
    // hook into the findProxy callback to set
    // the client's proxy
    client.findProxy = (url) {
    @@ -16,5 +16,5 @@ Dio dio = Dio();

    // this is a workaround to allow Charles to receive
    // SSL payloads when your app is running on Android
    (X509Certificate cert, String host, int port) => Platform.isAndroid;
    client.badCertificateCallback = (X509Certificate cert, String host, int port) => Platform.isAndroid;
    }
  4. jamesdixon created this gist Aug 30, 2019.
    20 changes: 20 additions & 0 deletions dio-proxy.dart
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    // make sure to replace <YOUR_LOCAL_IP> with
    // the external IP of your computer.
    String proxy = '<YOUR_LOCAL_IP>:8888';

    // create a new Dio instance
    Dio dio = Dio();

    // tap into the onHttpClientCreate callback
    // to configure the proxy just as we did earlier
    (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) client.badCertificateCallback =
    // hook into the findProxy callback to set
    // the client's proxy
    client.findProxy = (url) {
    return 'PROXY $proxy'?;
    };

    // this is a workaround to allow Charles to receive
    // SSL payloads when your app is running on Android
    (X509Certificate cert, String host, int port) => Platform.isAndroid;
    }