All Projects → ajinasokan → flutter_curl

ajinasokan / flutter_curl

Licence: MIT license
Flutter plugin to use libcurl for HTTP calls

Programming Languages

dart
5743 projects
CMake
9771 projects
C++
36643 projects - #6 most used programming language
ruby
36898 projects - #4 most used programming language
swift
15916 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to flutter curl

Node Libcurl
libcurl bindings for Node.js
Stars: ✭ 447 (+964.29%)
Mutual labels:  curl, libcurl, quic
Curl For Win
Reproducible curl (and OpenSSL) binaries for Windows
Stars: ✭ 352 (+738.1%)
Mutual labels:  curl, libcurl
request-extra
⚡️ Extremely stable HTTP request module built on top of libcurl with retries, timeouts and callback API
Stars: ✭ 14 (-66.67%)
Mutual labels:  curl, libcurl
Curlcpp
An object oriented C++ wrapper for CURL (libcurl)
Stars: ✭ 462 (+1000%)
Mutual labels:  curl, libcurl
curly.hpp
Simple cURL C++17 wrapper
Stars: ✭ 48 (+14.29%)
Mutual labels:  curl, libcurl
Curlsharp
CurlSharp - .Net binding and object-oriented wrapper for libcurl.
Stars: ✭ 153 (+264.29%)
Mutual labels:  curl, libcurl
Curl
A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP. libcurl offers a myriad of powerful features
Stars: ✭ 22,875 (+54364.29%)
Mutual labels:  curl, libcurl
Everything Curl
The book documenting the curl project, the curl tool, libcurl and everything related to this.
Stars: ✭ 885 (+2007.14%)
Mutual labels:  curl, libcurl
Katipo
HTTP2 client for Erlang based on libcurl and libevent
Stars: ✭ 90 (+114.29%)
Mutual labels:  curl, libcurl
Gmod Chttp
A HTTP()-compatible wrapper for curl in Garry's Mod.
Stars: ✭ 39 (-7.14%)
Mutual labels:  curl, libcurl
libopenTIDAL
TIDAL API interface written in ANSI C
Stars: ✭ 17 (-59.52%)
Mutual labels:  curl, libcurl
Lua Curlv3
Lua binding to libcurl
Stars: ✭ 197 (+369.05%)
Mutual labels:  curl, libcurl
fortran-curl
Fortran 2008 interface bindings to libcurl
Stars: ✭ 25 (-40.48%)
Mutual labels:  curl, libcurl
cpr
C++ Requests: Curl for People, a spiritual port of Python Requests.
Stars: ✭ 5,005 (+11816.67%)
Mutual labels:  libcurl
get header
This function is similar to the get_headers function
Stars: ✭ 35 (-16.67%)
Mutual labels:  curl
CwsShareCount
PHP class to get social share count for Delicious, Facebook, Google+, Linkedin, Pinterest, Reddit, StumbleUpon and Twitter.
Stars: ✭ 13 (-69.05%)
Mutual labels:  curl
domcurl
cUrl-like utility for fetching a resource (in this case we will run JS and return after network is idle) - great for JS heavy apps
Stars: ✭ 84 (+100%)
Mutual labels:  curl
onymous-plurk
Anonymous Plurk Cross-matching Tool - Plurk偷偷說交叉比對工具
Stars: ✭ 20 (-52.38%)
Mutual labels:  curl
owt-sdk-quic
C++ server and client APIs for WebTransport.
Stars: ✭ 75 (+78.57%)
Mutual labels:  quic
quic vs tcp
A Survey and Benchmark of QUIC
Stars: ✭ 41 (-2.38%)
Mutual labels:  quic

libcurl for Flutter

Flutter plugin to use libcurl for HTTP calls in Flutter Android & iOS apps. HTTP stack built in to Dart as part of dart:io supports only HTTP 1.1. This plugin aims to bring upto date features in connectivity available in libcurl such as:

  • HTTP2 with Nghttp2
  • Automatic upgrade to HTTP2 from 1.1 with ALPN TLS extension
  • Brotli compression
  • Experimental HTTP3 and alt-svc support (http3 branch)

Getting started

Add to project:

flutter pub add flutter_curl

Example usage:

import 'package:flutter_curl/flutter_curl.dart';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart' as paths;

// Initialize client
Client client = Client(
      verbose: true,
      interceptors: [
        // HTTPCaching(),
      ],
    );
await client.init();

// Send request
final res = await c.send(Request(
      method: "GET",
      url: "https://ajinasokan.com/",
      headers: {
          "user-agent": "myapp-v1.0/android9"
      },
      // body
      // body: RequestBody.raw(utf8.encode("hello world")),
      // body: RequestBody.string("hello world"),
      // body: RequestBody.form({"age": "10", "hello": "world"}),
      // body: RequestBody.multipart([
      //    Multipart(name: "age", data: "24"),
      //    Multipart(name: "hello", data: "world"),
      //    Multipart.file(
      //      name: "fieldname",
      //      path: "/sdcard/todo.txt",
      //      filename: "filename.txt",
      //    ),
      //  ]),
    },
));

// Read response
print("Status: ${res.statusCode}");
print("HTTP: ${res.httpVersion}");
res.headers.forEach((key, value) {
    print("$key: $value");
});
print(res.text());

How it works

This plugin uses custom built libcurl libraries distributed via releases. If you would like to build these by yourself follow instructions in cURL project. The configuration used for above mentioned builds is:

  • Ngtcp2 for HTTP2
  • libbrotli
  • NDK min SDK: 21 (armv7a, arm64, x86_64), iOS min SDK: 8.0 (arm64, x86_64)
  • Android binaries are packaged as aar and iOS binary as framework

This will be downloaded once the project builds for Android or when pod install happens for iOS. In Android these binaries are dynamically linked and in iOS it is statically linked.

The cURL APIs are accessed directly in a different isolate in Flutter using the dart:ffi APIs(beta). Isolate is used to avoid unresponsiveness in the app as the cURL APIs are blocking.

Reducing APK size

Flutter's --target-platform argument only removes its own native binaries for unspecified architectures. This is not adding abiFilters to the project gradle. So this doesn't remove the binaries for unspecified architectures from the plugins like flutter_curl.

A workaround suggested in flutter_vpn project is to add this logic to the project gradle config manually like below:

android {
    ...
    buildTypes {
        ...
        release {
            ...
            ndk {
                if (!project.hasProperty('target-platform')) {
                    abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64'
                } else {
                    def platforms = project.property('target-platform').split(',')
                    def platformMap = [
                            'android-arm'  : 'armeabi-v7a',
                            'android-arm64': 'arm64-v8a',
                            'android-x86'  : 'x86',
                            'android-x64'  : 'x86_64',
                    ]
                    abiFilters = platforms.stream().map({ e ->
                        platformMap.containsKey(e) ? platformMap[e] : e
                    }).toArray()
                }
            }
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].