dakaz / esp8266-restclient Goto Github PK
View Code? Open in Web Editor NEWThis project forked from csquared/arduino-restclient
Arduino RESTful HTTP Request Library
License: MIT License
This project forked from csquared/arduino-restclient
Arduino RESTful HTTP Request Library
License: MIT License
Hi,
I'm wondering if server sent events (SSE), will be covered in this repository?
Thanks a lot for your work.
Hi, i use your library successfully with ESP8266 for some months now...
Recently i had to switch to ESP32 due to performance issues on EpaperDisplays, now in general your library is based on esp8266wifi.h however ESP32 requires wifi.h which seems to be the new naming.....at least for ESP32. So I did change the library include in the header file of your code....no errors.....but also no output when i try to make a get on a restful server....which works well on ESP8266.
Any idea what needs to be considered on top in order to make it work with "wifi.h"?
Highly appreciate your thoughts and check. Regards Norbert
How about this case:
server nginx config
server {
server_name api.dev;
}
server certificate CN = api.dev
or [ext] subjectAltName = DNS:api.dev,DNS:*.api.dev
https://github.com/bscheshirwork/docker-yii2-app-advanced-rbac/blame/api/docs/about-api-ssl.md#L113
connect to server use IP of host machine and verify by hostHeader
, not by host
const char* host = "192.168.1.39";
const char* hostHeader = "api.dev";
const int httpsPort = 8082;
String url = "/v1/feedback/create";
// Use web browser to view and copy SHA1 fingerprint of the certificate or use
// openssl x509 -in server.crt -fingerprint
const char* fingerprint = "A1 1F 18 32 A7 2C CE 2B 74 F8 0E 35 A7 11 16 11 7F 61 22 C9";
...
setup(){
...
//connect to host
Serial.print("connecting to ");
Serial.println((String)host);
if (!espClient.connect(host, httpsPort)) {
Serial.println("connection failed");
return;
}
if (espClient.verify(fingerprint, hostHeader)) {
Serial.println("certificate matches");
} else {
Serial.println("certificate doesn't match");
}
Serial.print("requesting URL: ");
Serial.println(url);
espClient.print(String("POST ") + url + " HTTP/1.1\r\n" +
"Host: " + hostHeader + "\r\n" +
"User-Agent: MP3ESP8266\r\n" +
"Connection: close\r\n\r\n");
}
https://github.com/bscheshir/esp8266-mp3-web-server/blob/b1f0231c3f8681c39d040d99b39d200282ad1ab3/WiFiWebServerMP3.ino#L40-L46
https://github.com/bscheshir/esp8266-mp3-web-server/blob/b1f0231c3f8681c39d040d99b39d200282ad1ab3/WiFiWebServerMP3.ino#L185-L206
I think about use your library, but
in this library I can see only equials sslClient.verify(...,host)
; sslClient.connect(host,...)
esp8266-restclient/RestClient.cpp
Lines 161 to 167 in 4e2069f
C:\tmp\esp8266-restclient\examples\simple_POST\RestClient.cpp: In member function 'int RestClient::request(const char*, const char*, const char*, String*)':
C:\tmp\esp8266-restclient\examples\simple_POST\RestClient.cpp:167:27: error: 'class BearSSL::WiFiClientSecure' has no member named 'verify'
167 | if (sslClient.verify(fingerprint, host)) {
| ^~~~~~
Hi,
I get the following error when using (compiling with) the library:
undefined reference to `RestClient::begin(unsigned char*)
How can I fix it?
The following code put in RestClient
constructor will not work (by default all member pointers have undefined values, not NULL
s):
if (contentType == NULL) {
contentType = "application/x-www-form-urlencoded"; // default
}
Working solution would be just getting rid of if
clause:
contentType = "application/x-www-form-urlencoded";
Observed on WeMos whild sending POST
requests.
Hi,
first, thanks for your work. I have a strange behaviuor using your RestClient library as a pointer.
I define a RestClient object as a pointer, because i need to create it after loading the collector host IP from a config file:
RestClient *restClient;
Later i initialize the object:
...
restClient = new RestClient(config.collector_host);
....
and i send data via POST like:
char query[128];
String response="";
...
sprintf(query,"key=%s&ts=%d&t=%s&p=%s&h=%s&uv=%d&pm25=%s&pm10=%s",config.api_key,data.ts,data.temp,data.pres,data.hum,data.uv,data.pm25,data.pm10);
statusCode = restClient->post("/rest/data/put", query, &response);
but watching data with tcpdump, i see strange behavour in header like:
POST /rest/data/put HTTP/1.1
Host: [host]:80
Connection: close
Content-Length: 36
**Content-Type: L.).**
key=KEY&t=21.60&h=39.80
Any help really appreciated !
RestClient::request() adds a blank line between headers and request body if the method is GET, but this blank line is needed for other methods too, such as POST.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.