body() - nomadnt-iot/uHTTP GitHub Wiki

body()

Description

Get processed request body.

Syntax

server.body();

Parameters

None

Returns

const char array max 255 chars length. It is possible to change this value from uHTTP.h

Example

#include <SPI.h>
#include <Ethernet.h>
#include <uHTTP.h>

byte macaddr[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
byte ip4addr[4] = {192, 168, 0, 254};

uHTTP server = uHTTP(80);

void setup(){
    Ethernet.begin(macaddr, ip4addr);

    Serial.print(F("Starting uHTTP at "));
    Serial.print(Ethernet.localIP());
    Serial.println(":80");

    server.begin();
}

void loop(){
    EthernetClient response = server.available();
    if(response){
        Serial.println(server.body());

        response.println("HTTP/1.1 200 OK");
        response.println("Content-Type: text/plain");
        response.println();
        response.println("Hello World!");
        response.stop();
    }
}
⚠️ **GitHub.com Fallback** ⚠️