http-status-codes-cpp
http-status-codes-cpp copied to clipboard
Feature Request: Add an HttpStatusCodes_Ardunio.(h/cpp)
Hello,
This code is extremely useful and thank you for creating it.
If possible, would you be able to produce an Arduino version of the library, and place it on PlatformIO?
Arduino faces some challenges which are not prevalent on other platforms. Primarily RAM and Flash constraints. In the microcontroller world, C strings are always stored in RAM, so special functions must be called to store it in program memory. Similarly, not inlining the function saves Flash memory.
My approach to converting the library was to have a header with:
#include <WString.h>
...
String reasonPhrase(int code);
...
And a cpp file with:
#include "HttpStatusCodes_Arduino.h"
String reasonPhrase(int code) {
...
case 100: return F("Continue");
...
}
I just did a replace of "std::String(" with "F(".
Why No Pull Request
I would have to get my bosses approval to submit a pull request, but can say exactly what I did, as it isn't a company secret or anything. Isn't IP law fun...
Update. I have received permission to share the code I have written. Expect a pull request shortly.