Hello everyone,
I'm currently testing the serial communication between an ESP8266-01 and an Arduino Mega 2560.
To do this, I use a web page provided by the ESP and send commands via the serial port to the Arduino.
Wishing to improve the web page, I use BootStrap and JQuery.
Until now, the main page loaded a JavaScript file to handle user interaction.
I've since added a CSS sheet and now only this one is loaded (I checked the network flows using the development tools of my web browsers, Chrome, Firefox). The JS file is not delivered by the ESP web server without 404 or other errors.
Here's the code used.
If some kind soul could tell me where the problem comes from, I'd like to thank them in advance.
Here the main.cpp file
#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ArduinoJson.h>
#if ARDUINO_OTA_ON == 1
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#endif
#if DEBUG_ON == 1
#include <RemoteDebug.h>
#endif
#include <uri/UriBraces.h>
/* Personal Headers */
#include "main.h"
#include "HtmlCodes.h"
#include "HtmlPages.h"
#include "JSFunctions.h"
#include "HtmlCSS.h"
//#include "WebServerHandlers.h"
String hostName = "esp01-dev";
String codeVersion = "Version 1.0 Sept 2023 by Arno";
// WiFi Router Login - change these to your router settings
const char* SSID = "**************";
const char* password = "****************";
// Setup GPIO2
int pinGPIO2 = 2; // To control Wifi LED
int ledStatus = 0; // 0=off,1=on,2=dimmed
int wifiStatus = LOW;
#if DEBUG_ON == 1
RemoteDebug Debug;
#endif
// Create the ESP Web Server on port 80
ESP8266WebServer server(80);
WiFiUDP ntpUDP;
NTPClient temps(ntpUDP, "fr.pool.ntp.org", 3600, 60000);
// Define default state
String state = "0";
String url = "";
/***********************************************************
* Handle assets
**********************************************************/
void handleAssets() {
String assetRequest = server.pathArg(0);
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Asset requested '" + assetRequest + "'");
#endif
if (assetRequest == "default.css") {
String cssFile = CSS_DEFAULT;
server.send(HttpStatus_OK, F("text/css"), cssFile);
} else if (assetRequest == "404.css") {
String cssFile = CSS_404;
server.send(HttpStatus_OK, F("text/css"), cssFile);
} else if (assetRequest == "functions.js") {
String jsFile = FUNCTIONS_JS;
server.send(HttpStatus_OK, F("text/javascript"), jsFile);
}
}
/***********************************************************
* HandleLED
**********************************************************/
void handleLED() {
if (!server.hasArg("state")) {
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] No arg 'state' passed -> Define led state to 'OFF'");
#endif
state = "0";
}
else
{
if (server.arg("state") != "") {
state = server.arg("state");
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Define led state to '" + state + "'.");
#endif
}
else {
state = "0";
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Define led state to '" + state + "'.");
#endif
}
}
ledControl(state);
DynamicJsonDocument response(32);
response["ledState"] = state;
String jsonResponse;
serializeJson(response, jsonResponse);
server.send(HttpStatus_OK, F("application/json"), jsonResponse);
}
/***********************************************************
* HandleNotFound
**********************************************************/
void handleNotFound() {
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Undefined route received.");
#endif
String page404 = PAGE_404;
page404.replace("__TITLE__", "404");
page404.replace("__URL__", url);
server.send(HttpStatus_NotFound, F("text/html"), page404); // Send HTTP status 404 (Not Found) when there's no handler for the URI in the request
}
/***********************************************************
* HandleRoot
**********************************************************/
void handleRoot() {
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Route root received.");
#endif
ledControl(state);
String indexPage = PAGE_INDEX;
indexPage.replace("__TITLE__", "ESP8266 ARCOBOXE Demo");
indexPage.replace("__URL__", url);
server.send(HttpStatus_OK, F("text/html"), indexPage);
}
/***********************************************************
* InitOTA
**********************************************************/
#if ARDUINO_OTA_ON == 1
void initOTA() {
// Port defaults to 8266
// ArduinoOTA.setPort(8266);
// hostName defaults to esp8266-[ChipID]
char otaHostName[hostName.length()];
hostName.toCharArray(otaHostName, hostName.length());
ArduinoOTA.setHostname(otaHostName);
// No authentication by default
// ArduinoOTA.setPassword("admin");
// Password can be set with it's md5 value as well
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
ArduinoOTA.onStart([]() {
String type;
if (ArduinoOTA.getCommand() == U_FLASH) {
type = "sketch";
}
else { // U_FS
type = "filesystem";
}
// NOTE: if updating FS this would be the place to unmount FS using FS.end()
Serial.println("Start updating " + type);
});
ArduinoOTA.onEnd([]() {
Serial.println("\nEnd");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) {
Serial.println("Auth Failed");
}
else if (error == OTA_BEGIN_ERROR) {
Serial.println("Begin Failed");
}
else if (error == OTA_CONNECT_ERROR) {
Serial.println("Connect Failed");
}
else if (error == OTA_RECEIVE_ERROR) {
Serial.println("Receive Failed");
}
else if (error == OTA_END_ERROR) {
Serial.println("End Failed");
}
});
ArduinoOTA.begin();
Serial.println("STATUS=OTA Ok");
}
#endif
/***********************************************************
* LEDControl
**********************************************************/
void ledControl(String state) {
String command = "STATE_LED=" + state;
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Send command: " + command);
#endif
Serial.println(command);
}
/***********************************************************
* Setup debug
**********************************************************/
#if DEBUG_ON == 1
void setupDebug() {
Debug.showColors(true);
Debug.begin(hostName);
Debug.println("[" + temps.getFormattedTime() + "] " + codeVersion);
}
#endif
/***********************************************************
* Setup NTP
**********************************************************/
void setupNTP() {
temps.begin();
temps.update();
temps.setTimeOffset(7200);
char command[100];
sprintf(command, "CMD_NTP=%lu", temps.getEpochTime());
Serial.println(command);
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Send: " + command);
#endif
}
/***********************************************************
* Setup serial
**********************************************************/
void setupSerial() {
Serial.begin(115200);
while (!Serial) {
delay(10);
}
}
/***********************************************************
* Setup Webserver
**********************************************************/
void setupWebServer() {
server.on(F("/"), HTTP_GET, handleRoot);
server.on(F("/"), HTTP_POST, handleLED);
server.on(UriBraces("/assets/{}"), HTTP_GET, handleAssets);
server.onNotFound(handleNotFound);
// Start the Web Server
server.begin();
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Web Server started");
Debug.print("[" + temps.getFormattedTime() + "] You can connect to the ESP8266 at this URL: ");
IPAddress ipa = WiFi.localIP();
uint8_t IP_array[4] = { ipa[0],ipa[1],ipa[2],ipa[3] };
String strIP =
String(IP_array[0]) + "." +
String(IP_array[1]) + "." +
String(IP_array[2]) + "." +
String(IP_array[3]);
url = "http://" + hostName + ".arcoboxe.org";
Debug.println("[" + temps.getFormattedTime() + "] " + url);
#endif
Serial.println("STATUS=Web server Ok");
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Send: STATUS=Web server Ok");
#endif
}
/***********************************************************
* Setup WiFi
**********************************************************/
void setupWifi() {
// Connect to WiFi network
WiFi.disconnect();
WiFi.hostname(hostName);
WiFi.mode(WIFI_STA);
WiFi.begin(SSID, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
digitalWrite(pinGPIO2, wifiStatus);
wifiStatus = !wifiStatus;
}
digitalWrite(pinGPIO2, HIGH);
//hostName = WiFi.getHostname();
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Connected to WiFi");
#endif
if (MDNS.begin(hostName)) { // Start the mDNS responder for hostName.local
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] mDNS responder started");
#endif
MDNS.addService("http", "tcp", 80);
MDNS.addService("telnet", "tcp", 23);
}
else {
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Error setting up MDNS responder!");
#endif
}
#if DEBUG_ON == 1
Debug.println("[" + temps.getFormattedTime() + "] Web server Ok");
#endif
}
/***********************************************************
* Setup Wifi LED
**********************************************************/
void setupWifiLED() {
pinMode(pinGPIO2, OUTPUT);
digitalWrite(pinGPIO2, !wifiStatus);
}
/***********************************************************
* Global setup
**********************************************************/
void setup() {
#if DEBUG_ON == 1
setupDebug();
#endif
setupSerial();
setupWifiLED();
setupWifi();
setupNTP();
setupWebServer();
#if ARDUINO_OTA_ON == 1
initOTA();
#endif
ledControl(state);
}
/***********************************************************
* Loop
**********************************************************/
void loop() {
#if ARDUINO_OTA_ON == 1
ArduinoOTA.handle();
#endif
#if DEBUG_ON == 1
Debug.handle();
#endif
server.handleClient();
}
the HtmlPages.h file
#ifndef _HTML_PAGES_H_
#define _HTML_PAGES_H_
const char PAGE_INDEX[] PROGMEM = R"=====(
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name = "viewport" content = "width = device-width, initial-scale = 1.0, maximum-scale = 1.0, user-scalable=0">
<link href="data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAA/4QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAERABAAEAEBAQABAQEBABAAEAEQARABAQABAQABAAAQARAAEQARAAAAAAAAAAAAAAAAAAAAAAEREAEQAQAAAQAAEAEBAAABAAAAAQEAAAERAAEQAREAAQAAEAABABABAAAQAQEAEAEREAEQAREAAAAAAAAAAAD//wAA2N0AAKuqAADdmQAArrsAANnMAAD//wAA//8AAIZvAAC9rwAAv68AAI5jAAC97QAAva0AAIZjAAD//wAA" rel="icon" type="image/x-icon">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link href="__URL__/assets/default.css" rel="stylesheet"/>
<title>__TITLE__</title>
</head>
<body>
<br/><br/>
<table style="width: 25%;">
<tr>
<td id="ledState" colspan="2" style="text-align: center">LED is Off</td>
</tr>
<tr>
<td>Turn the LED</td><td><button id="btnOnOff" class="btn btn-100 btn-success">ON</button></td>
</tr>
<tr>
<td>Set LED to</td><td><button id="btnDim" class="btn btn-100 btn-warning">DIM</a></td>
</tr>
</table>
<script src="__URL__/assets/functions.js"/>
</body>
</html>
)=====";
const char PAGE_404[] PROGMEM = R"=====(
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name = "viewport" content = "width = device-width, initial-scale = 1.0, maximum-scale = 1.0, user-scalable=0">
<link href="data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAA/4QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAERABAAEAEBAQABAQEBABAAEAEQARABAQABAQABAAAQARAAEQARAAAAAAAAAAAAAAAAAAAAAAEREAEQAQAAAQAAEAEBAAABAAAAAQEAAAERAAEQAREAAQAAEAABABABAAAQAQEAEAEREAEQAREAAAAAAAAAAAD//wAA2N0AAKuqAADdmQAArrsAANnMAAD//wAA//8AAIZvAAC9rwAAv68AAI5jAAC97QAAva0AAIZjAAD//wAA" rel="icon" type="image/x-icon">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<title>__TITLE__</title>
<link href="__URL__/assets/404.css" rel="stylesheet"/>
</head>
<body>
<div id="content">
<h1>404</h1>
Page not found
<br/>
<br/>
<a href="__URL__" class="btn btn-dark">Retour</a>
</div>
<script src="__URL__/assets/functions.js"/>
</body>
</html>
)=====";
#endif
the HtmlCSS.h file
#ifndef _CSS_PAGES_H_
#define _CSS_PAGES_H_
const char CSS_DEFAULT[] PROGMEM = R"=====(
.btn-100 {
width: 100%;
}
)=====";
const char CSS_404[] PROGMEM = R"=====(
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
display: table
}
#content {
display: table-cell;
text-align: center;
vertical-align: middle;
}
)=====";
#endif
the JSFunctions.h file
#ifndef _JS_PAGES_H_
#define _JS_PAGES_H_
const char FUNCTIONS_JS[] PROGMEM = R"=====(
$(function() {
$("#btnOnOff").on("click", function() {
var ledState;
if ($(this).text() == "ON") {
ledState = "1";
} else {
ledState = "0";
}
$.ajax({
url: '/',
type: 'POST',
data: { state: ledState},
success: function (data, status, xhr) {
if (data.ledState == 1 ) {
$("#btnOnOff").removeClass("btn-success").addClass("btn-secondary").text("OFF");
} else {
$("#btnOnOff").removeClass("btn-ssecondary").addClass("btn-success").text("ON");
}
},
error: function (jqXhr, textStatus,errorMessage) {
alert("Error !!");
}
} );
} );
$("#btnDim").on("click", function() {
var ledState;
if ($(this).text() == "DIM") {
ledState = "2";
} else {
ledState = "1";
}
$.ajax({
url: '/',
type: 'POST',
data: { state: ledState},
success: function (data, status, xhr) {
if (data.ledState == 2 ) {
$("#btnDim").removeClass("btn-warning").addClass("btn-success").text("ON");
$("#btnOnOff").removeClass("btn-success").addClass("btn-secondary").text("OFF");
} else {
$("#btnDim").removeClass("btn-success").addClass("btn-warning").text("DIM");
}
},
error: function (jqXhr, textStatus,errorMessage) {
alert("Error !!");
}
} );
} );
});
)=====";
#endif
and the HtmlCodes.h file
#ifndef HTTPSTATUSCODES_C_H_
#define HTTPSTATUSCODES_C_H_
/*####### 1xx - Informational #######*/
/* Indicates an interim response for communicating connection status
* or request progress prior to completing the requested action and
* sending a final response.
*/
#define HttpStatus_Continue 100 /*!< Indicates that the initial part of a request has been received and has not yet been rejected by the server. */
#define HttpStatus_SwitchingProtocols 101 /*!< Indicates that the server understands and is willing to comply with the client's request, via the Upgrade header field, for a change in the application protocol being used on this connection. */
#define HttpStatus_Processing 102 /*!< Is an interim response used to inform the client that the server has accepted the complete request, but has not yet completed it. */
#define HttpStatus_EarlyHints 103 /*!< Indicates to the client that the server is likely to send a final response with the header fields included in the informational response. */
/*####### 2xx - Successful #######*/
/* Indicates that the client's request was successfully received,
* understood, and accepted.
*/
#define HttpStatus_OK 200 /*!< Indicates that the request has succeeded. */
#define HttpStatus_Created 201 /*!< Indicates that the request has been fulfilled and has resulted in one or more new resources being created. */
#define HttpStatus_Accepted 202 /*!< Indicates that the request has been accepted for processing, but the processing has not been completed. */
#define HttpStatus_NonAuthoritativeInformation 203 /*!< Indicates that the request was successful but the enclosed payload has been modified from that of the origin server's 200 (OK) response by a transforming proxy. */
#define HttpStatus_NoContent 204 /*!< Indicates that the server has successfully fulfilled the request and that there is no additional content to send in the response payload body. */
#define HttpStatus_ResetContent 205 /*!< Indicates that the server has fulfilled the request and desires that the user agent reset the \"document view\", which caused the request to be sent, to its original state as received from the origin server. */
#define HttpStatus_PartialContent 206 /*!< Indicates that the server is successfully fulfilling a range request for the target resource by transferring one or more parts of the selected representation that correspond to the satisfiable ranges found in the requests's Range header field. */
#define HttpStatus_MultiStatus 207 /*!< Provides status for multiple independent operations. */
#define HttpStatus_AlreadyReported 208 /*!< Used inside a DAV:propstat response element to avoid enumerating the internal members of multiple bindings to the same collection repeatedly. [RFC 5842] */
#define HttpStatus_IMUsed 226 /*!< The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance. */
/*####### 3xx - Redirection #######*/
/* Indicates that further action needs to be taken by the user agent
* in order to fulfill the request.
*/
#define HttpStatus_MultipleChoices 300 /*!< Indicates that the target resource has more than one representation, each with its own more specific identifier, and information about the alternatives is being provided so that the user (or user agent) can select a preferred representation by redirecting its request to one or more of those identifiers. */
#define HttpStatus_MovedPermanently 301 /*!< Indicates that the target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs. */
#define HttpStatus_Found 302 /*!< Indicates that the target resource resides temporarily under a different URI. */
#define HttpStatus_SeeOther 303 /*!< Indicates that the server is redirecting the user agent to a different resource, as indicated by a URI in the Location header field, that is intended to provide an indirect response to the original request. */
#define HttpStatus_NotModified 304 /*!< Indicates that a conditional GET request has been received and would have resulted in a 200 (OK) response if it were not for the fact that the condition has evaluated to false. */
#define HttpStatus_UseProxy 305 /*!< \deprecated \parblock Due to security concerns regarding in-band configuration of a proxy. \endparblock The requested resource MUST be accessed through the proxy given by the Location field. */
#define HttpStatus_TemporaryRedirect 307 /*!< Indicates that the target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI. */
#define HttpStatus_PermanentRedirect 308 /*!< The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs. [...] This status code is similar to 301 Moved Permanently (Section 7.3.2 of rfc7231), except that it does not allow rewriting the request method from POST to GET. */
/*####### 4xx - Client Error #######*/
/* Indicates that the client seems to have erred.
*/
#define HttpStatus_BadRequest 400 /*!< Indicates that the server cannot or will not process the request because the received syntax is invalid, nonsensical, or exceeds some limitation on what the server is willing to process. */
#define HttpStatus_Unauthorized 401 /*!< Indicates that the request has not been applied because it lacks valid authentication credentials for the target resource. */
#define HttpStatus_PaymentRequired 402 /*!< *Reserved* */
#define HttpStatus_Forbidden 403 /*!< Indicates that the server understood the request but refuses to authorize it. */
#define HttpStatus_NotFound 404 /*!< Indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists. */
#define HttpStatus_MethodNotAllowed 405 /*!< Indicates that the method specified in the request-line is known by the origin server but not supported by the target resource. */
#define HttpStatus_NotAcceptable 406 /*!< Indicates that the target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation. */
#define HttpStatus_ProxyAuthenticationRequired 407 /*!< Is similar to 401 (Unauthorized), but indicates that the client needs to authenticate itself in order to use a proxy. */
#define HttpStatus_RequestTimeout 408 /*!< Indicates that the server did not receive a complete request message within the time that it was prepared to wait. */
#define HttpStatus_Conflict 409 /*!< Indicates that the request could not be completed due to a conflict with the current state of the resource. */
#define HttpStatus_Gone 410 /*!< Indicates that access to the target resource is no longer available at the origin server and that this condition is likely to be permanent. */
#define HttpStatus_LengthRequired 411 /*!< Indicates that the server refuses to accept the request without a defined Content-Length. */
#define HttpStatus_PreconditionFailed 412 /*!< Indicates that one or more preconditions given in the request header fields evaluated to false when tested on the server. */
#define HttpStatus_ContentTooLarge 413 /*!< Indicates that the server is refusing to process a request because the request payload is larger than the server is willing or able to process. */
#define HttpStatus_PayloadTooLarge 413 /*!< Alias for HttpStatus_ContentTooLarge for backward compatibility. */
#define HttpStatus_URITooLong 414 /*!< Indicates that the server is refusing to service the request because the request-target is longer than the server is willing to interpret. */
#define HttpStatus_UnsupportedMediaType 415 /*!< Indicates that the origin server is refusing to service the request because the payload is in a format not supported by the target resource for this method. */
#define HttpStatus_RangeNotSatisfiable 416 /*!< Indicates that none of the ranges in the request's Range header field overlap the current extent of the selected resource or that the set of ranges requested has been rejected due to invalid ranges or an excessive request of small or overlapping ranges. */
#define HttpStatus_ExpectationFailed 417 /*!< Indicates that the expectation given in the request's Expect header field could not be met by at least one of the inbound servers. */
#define HttpStatus_ImATeapot 418 /*!< Any attempt to brew coffee with a teapot should result in the error code 418 I'm a teapot. */
#define HttpStatus_MisdirectedRequest 421 /*!< Indicates that the request was directed at a server that is unable or unwilling to produce an authoritative response for the target URI. */
#define HttpStatus_UnprocessableContent 422 /*!< Means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions. */
#define HttpStatus_UnprocessableEntity 422 /*!< Alias for HttpStatus_UnprocessableContent for backward compatibility. */
#define HttpStatus_Locked 423 /*!< Means the source or destination resource of a method is locked. */
#define HttpStatus_FailedDependency 424 /*!< Means that the method could not be performed on the resource because the requested action depended on another action and that action failed. */
#define HttpStatus_TooEarly 425 /*!< Indicates that the server is unwilling to risk processing a request that might be replayed. */
#define HttpStatus_UpgradeRequired 426 /*!< Indicates that the server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol. */
#define HttpStatus_PreconditionRequired 428 /*!< Indicates that the origin server requires the request to be conditional. */
#define HttpStatus_TooManyRequests 429 /*!< Indicates that the user has sent too many requests in a given amount of time (\"rate limiting\"). */
#define HttpStatus_RequestHeaderFieldsTooLarge 431 /*!< Indicates that the server is unwilling to process the request because its header fields are too large. */
#define HttpStatus_UnavailableForLegalReasons 451 /*!< This status code indicates that the server is denying access to the resource in response to a legal demand. */
/*####### 5xx - Server Error #######*/
/* Indicates that the server is aware that it has erred
* or is incapable of performing the requested method.
*/
#define HttpStatus_InternalServerError 500 /*!< Indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. */
#define HttpStatus_NotImplemented 501 /*!< Indicates that the server does not support the functionality required to fulfill the request. */
#define HttpStatus_BadGateway 502 /*!< Indicates that the server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request. */
#define HttpStatus_ServiceUnavailable 503 /*!< Indicates that the server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay. */
#define HttpStatus_GatewayTimeout 504 /*!< Indicates that the server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request. */
#define HttpStatus_HTTPVersionNotSupported 505 /*!< Indicates that the server does not support, or refuses to support, the protocol version that was used in the request message. */
#define HttpStatus_VariantAlsoNegotiates 506 /*!< Indicates that the server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process. */
#define HttpStatus_InsufficientStorage 507 /*!< Means the method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request. */
#define HttpStatus_LoopDetected 508 /*!< Indicates that the server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". [RFC 5842] */
#define HttpStatus_NotExtended 510 /*!< \deprecated \parblock Obsoleted as the experiment has ended and there is no evidence of widespread use. \endparblock
#define The policy for accessing the resource has not been met in the request. [RFC 2774] */
#define HttpStatus_NetworkAuthenticationRequired 511 /*!< Indicates that the client needs to authenticate to gain network access. */
#define HttpStatus_xxx_max 1023
#endif /* HTTPSTATUSCODES_C_H_ */