All Projects → tuanpmt → Esp Request

tuanpmt / Esp Request

Licence: apache-2.0
This project is no longer supported, please use

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Esp Request

Esphelper
A library to make using WiFi & MQTT on the ESP8266 easy.
Stars: ✭ 310 (+376.92%)
Mutual labels:  esp32, ota
Lws Esp32 Factory
Libwebsockets ESP32 Factory Application
Stars: ✭ 60 (-7.69%)
Mutual labels:  esp32, ota
Kurly
kurly is an alternative to the widely popular curl program, written in Golang.
Stars: ✭ 319 (+390.77%)
Mutual labels:  http-client, https
Netty Http Client
An asynchronous http client in Java, with a clean, callback-based API, using Netty 4.x
Stars: ✭ 295 (+353.85%)
Mutual labels:  http-client, https
Http Client
Async HTTP/1.1+2 client for PHP based on Amp.
Stars: ✭ 553 (+750.77%)
Mutual labels:  http-client, https
Microwebsrv2
The last Micro Web Server for IoTs (MicroPython) or large servers (CPython), that supports WebSockets, routes, template engine and with really optimized architecture (mem allocations, async I/Os). Ready for ESP32, STM32 on Pyboard, Pycom's chipsets (WiPy, LoPy, ...). Robust, efficient and documented!
Stars: ✭ 295 (+353.85%)
Mutual labels:  esp32, https
Isahc
The practical HTTP client that is fun to use.
Stars: ✭ 338 (+420%)
Mutual labels:  http-client, https
ESP32 BLE OTA Arduino
OTA update on ESP32 via BLE
Stars: ✭ 41 (-36.92%)
Mutual labels:  ota, esp32
Http
Event-driven, streaming HTTP client and server implementation for ReactPHP.
Stars: ✭ 507 (+680%)
Mutual labels:  http-client, https
Phin
Node HTTP client
Stars: ✭ 449 (+590.77%)
Mutual labels:  http-client, https
Blynk Library
Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc.
Stars: ✭ 3,305 (+4984.62%)
Mutual labels:  esp32, ota
Gun
HTTP/1.1, HTTP/2 and Websocket client for Erlang/OTP.
Stars: ✭ 710 (+992.31%)
Mutual labels:  http-client, https
Deviot
Sublime Text plugin for IoT development based in PlatformIO ecosystem (Arduino IDE)
Stars: ✭ 281 (+332.31%)
Mutual labels:  esp32, ota
Jetty.project
Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
Stars: ✭ 3,260 (+4915.38%)
Mutual labels:  http-client, https
electron-request
Zero-dependency, Lightweight HTTP request client for Electron or Node.js
Stars: ✭ 45 (-30.77%)
Mutual labels:  https, http-client
Mojito
An easy-to-use Elixir HTTP client, built on the low-level Mint library.
Stars: ✭ 333 (+412.31%)
Mutual labels:  http-client, https
SuperGreenOS
🧠 SuperGreenOS home farming automation software for esp32, all in one package, and controllable from your smartphone, pc, mac, linux, toaster, plumbus, whatnot...
Stars: ✭ 83 (+27.69%)
Mutual labels:  ota, esp32
esp32FOTA
Experiments in firmware OTA updates for ESP32 dev boards
Stars: ✭ 185 (+184.62%)
Mutual labels:  ota, esp32
Httpdirfs
A filesystem which allows you to mount HTTP directory listings, with a permanent cache. Now with Airsonic / Subsonic support!
Stars: ✭ 443 (+581.54%)
Mutual labels:  http-client, https
Fast Android Networking
🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀
Stars: ✭ 5,346 (+8124.62%)
Mutual labels:  http-client, https

Lightweight HTTP client for ESP32

Example

This project is no longer supported, please use

https://github.com/espressif/esp-idf/tree/master/components/esp_http_client

int download_callback(request_t *req, char *data, int len)
{
    req_list_t *found = req->response->header;
    while(found->next != NULL) {
        found = found->next;
        ESP_LOGI(TAG,"Response header %s:%s", (char*)found->key, (char*)found->value);
    }
    //or 
    found = req_list_get_key(req->response->header, "Content-Length");
    if(found) {
        ESP_LOGI(TAG,"Get header %s:%s", (char*)found->key, (char*)found->value);
    }
    ESP_LOGI(TAG,"%s", data);
    return 0;
}
static void request_task(void *pvParameters)
{
    request_t *req;
    int status;
    xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, false, true, portMAX_DELAY);
    ESP_LOGI(TAG, "Connected to AP, freemem=%d",esp_get_free_heap_size());
    // vTaskDelay(1000/portTICK_RATE_MS);
    req = req_new("http://httpbin.org/post"); 
    //or
    //request *req = req_new("https://google.com"); //for SSL
    req_setopt(req, REQ_SET_METHOD, "POST");
    req_setopt(req, REQ_SET_POSTFIELDS, "test=data&test2=data2");
    req_setopt(req, REQ_FUNC_DOWNLOAD_CB, download_callback);
    status = req_perform(req);
    req_clean(req);
    vTaskDelete(NULL);
}

Websocket

int websocket_cb(request_t *req, int status, void *buffer, int len)
{
    switch(status) {
        case WS_CONNECTED:
            ESP_LOGI(TAG, "websocket connected");
            req_write(req, "hello world", 11);
            break;
        case WS_DATA:
            ((char*)buffer)[len] = 0;
            ESP_LOGI(TAG, "websocket data = %s", (char*)buffer);
            req_close(req);
            break;
        case WS_DISCONNECTED:
            ESP_LOGI(TAG, "websocket disconnected");
            req_clean(req);
            req = NULL;
            break;
    }
    return 0;
}
void app()
{
    request_t *req = req_new("ws://echo.websocket.org"); // or wss://echo.websocket.org
    req_setopt(req, REQ_FUNC_WEBSOCKET, websocket_cb);
    req_perform(req);
}

Usage

API

Function

  • req_new
  • req_setopt
  • req_clean

Options for req_setopt

  • REQ_SET_METHOD - req_setopt(req, REQ_SET_METHOD, "GET");//or POST/PUT/DELETE
  • REQ_SET_HEADER - req_setopt(req, REQ_SET_HEADER, "HeaderKey: HeaderValue");
  • REQ_SET_HOST - req_setopt(req, REQ_SET_HOST, "google.com"); //or 192.168.0.1
  • REQ_SET_PORT - req_setopt(req, REQ_SET_PORT, "80");//must be string
  • REQ_SET_PATH - req_setopt(req, REQ_SET_PATH, "/path");
  • REQ_SET_SECURITY
  • REQ_SET_URI - req_setopt(req, REQ_SET_URI, "http://uri.com"); //will replace host, port, path, security and Auth if present
  • REQ_SET_DATAFIELDS
  • REQ_SET_UPLOAD_LEN - Not effect for now
  • REQ_FUNC_DOWNLOAD_CB - req_setopt(req, REQ_FUNC_DOWNLOAD_CB, download_callback);
  • REQ_FUNC_UPLOAD_CB
  • REQ_FUNC_WEBSOCKET
  • REQ_REDIRECT_FOLLOW - req_setopt(req, REQ_REDIRECT_FOLLOW, "true"); //or "false"

URI format

Todo

  • [x] Support URI parser
  • [x] Follow redirect
  • [x] Support SSL
  • [x] Support Set POST Fields (simple)
  • [x] Support Websocket & Websocket Secure
  • [ ] Support Basic Auth
  • [ ] Support Upload multipart
  • [ ] Support Cookie

Known Issues

  • Uri parse need more work

Authors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].