Skip to content

Arduino ESP8266 Http Request Library

License

Notifications You must be signed in to change notification settings

Subtixx/esp8266http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP8266Http

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.

Table of contents

Examples

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

HTTP GET Request

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.
    )
);

HTTP POST Request

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.
    )
);

HTTP PATCH Request

The library doesn't support PATCH requests yet. If you need it please open an issue

HTTP PUT Request

The library doesn't support PUT requests yet. If you need it please open an issue

HTTP DELETE Request

The library doesn't support DELETE requests yet. If you need it please open an issue

Sending custom headers

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"),
        }
    )
);

Releases

No releases published

Packages

No packages published

Languages