ESP8266Http is an HTTP Request library, despite it's name ESP8266Http can support other architectures, I just don't have the hardware to test it on.
By default the library sets the following headers wether you specify it or not:
User-Agent: ESP8266Http/1.0.0
Accept: */*
If it's a POST request it also specifies:
Content-Type: application/x-www-form-urlencoded
Content-Length
For more in-depth examples look in the examples folder
This will make an HTTP GET Request to https://api.ipify.org
HttpResponse response = Esp8266Http::Request(
HttpRequest(
HttpRequest::GET, // Specifies that this should be a GET request.
"https://api.ipify.org" // Specifies the URL where it should make the request to.
)
);
This will make an HTTP POST Request to https://htttpbin.org/post with someValue
set to 1024
HttpResponse response = Esp8266Http::Request(
HttpRequest(
HttpRequest::POST, // Specifies that this should be a POST request.
"https://httpbin.org/post?someValue=1024" // Specifies the URL where it should make the request to.
)
);
The library doesn't support PATCH
requests yet. If you need it please open an issue
The library doesn't support PUT
requests yet. If you need it please open an issue
The library doesn't support DELETE
requests yet. If you need it please open an issue
Sometimes it's necessary to send custom headers like cookies. This example shows how to do that.
HttpResponse response = Esp8266Http::Request(
HttpRequest(
HttpRequest::GET, // Specifies that this should be a GET request.
"https://httpbin.org/cookies", // Specifies the URL where it should make the request to.
{
std::make_pair("Cookie", "logged_in=yes"),
}
)
);