简体   繁体   中英

How to specify Flutter/dart HTTP protocol version (HTTP/1.1, --http1.1)

I am using dart:http to make post request but it seems I cannot specify HTTP1.1 version which is required by target api. Ideally I need to re-create following request in dart:

curl -X POST --http1.1 "https://api.dummyapi.com/v1/route" -H "accept: text/plain" -H "Authorization: 000000-000000-000000-000000" -H "Content-Type: application/json-patch+json" -d "{}"

My current version is this:

    final url = Uri.parse('https://api.dummyapi.com/v1/route');

    final response = await http.post(url, headers: {
      'Authorization': '000000-000000-000000-000000',
      'accept': 'text/plain',
      'Content-Type': 'application/json'
    });```
Checked the following code example



  Future createUserExample(Map<String,dynamic> data) async {
final http.Response response = await http.post(
    'https://api.dummyapi.com/v1/route',
    headers: <String, String>{
      'Authorization': '000000-000000-000000-000000',
      'accept': 'text/plain',
      'Content-Type': 'application/json'
    },
    body: data,
);
return response;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM