isoos / http_client

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

Add POST Support to Curl Client #9

Closed andresruizdev closed 3 years ago

andresruizdev commented 3 years ago

I am making my first pull request to add support to POST method using CURL. This allows to add basic String value or Json String value to the request as -d or --data parameter. I will add more methods and features as soon as possible.

Post Test

I'm using this feature for a personal project and testing this feature I got a successful result.

Code used to make request:

final client = CurlClient();
final rs = await client.send(Request('POST', 'http://192.168.4.1:6104/', body: jsonTemplate));
if(rs.statusCode == 200){
  final textContent = await rs.readAsString();
  print(textContent);
}

Data used in jsonTemplate variable:

jsonTemplate = "{"ap":{"ssid":"NetworkSSID","password":"NetworkPass","ip":"192.168.4.1","netmask":"255.255.255.0","gateway":"192.168.4.1"},"station":{"ssid":"MainNetSSID","password":"MainNetPass","enable":"true","status":0}}";

Received response

image

isoos commented 3 years ago

published a new version with this change, thanks!