1
0
mirror of https://github.com/arduino-libraries/ArduinoHttpClient.git synced 2025-06-16 02:21:40 +03:00

Add optional content type, content length and body parameters to post, put, and startRequest

Also, flush client RX data in start request, if state is ready body.
This commit is contained in:
Sandeep Mistry
2016-06-22 12:10:47 -04:00
parent 4ab54b0a1a
commit c3023b25ee
7 changed files with 134 additions and 53 deletions

View File

@ -50,14 +50,10 @@ void setup() {
void loop() {
Serial.println("making PUT request");
String contentType = "application/x-www-form-urlencoded";
String putData = "name=light&age=46";
client.beginRequest();
client.put("/");
client.sendHeader("Content-Type", "application/x-www-form-urlencoded");
client.sendHeader("Content-Length", putData.length());
client.endRequest();
client.write((const byte*)putData.c_str(), putData.length());
client.put("/", contentType, putData);
// read the status code and content length of the response
statusCode = client.responseStatusCode();