-
Notifications
You must be signed in to change notification settings - Fork 14
Feature/add options method #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feature/add options method #20
Conversation
| void ArduinoHttpServer::AbstractStreamHttpReply::addHeader(const String& name, const String &value) { | ||
| if (m_headerCount == MAX_HEADERS) return; | ||
|
|
||
| m_headerNames[m_headerCount] = name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not a struct with a name and value pair?
| // First strtok call, initialize with cached line buffer. | ||
| // len("DELETE") + 1 for terminating null = 7 | ||
| FixString<7U> token(strtok_r(lineBuffer, " ", &m_lineBufferStrTokContext)); | ||
| // len("OPTIONS") + 1 for terminating null = 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // len("OPTIONS") + 1 for terminating null = 7 | |
| // len("OPTIONS") + 1 for terminating null = 8 |
|
|
||
| #include "ArduinoHttpServerDebug.h" | ||
|
|
||
| #define MAX_HEADERS 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change it to modern C++ typesafe constexpr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can give it a shot, but I haven't used those ever (I am not a native C++ speaker).
|
|
||
| private: | ||
|
|
||
| String m_headerNames[MAX_HEADERS]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't mind, I think I will rewrite it to become an array of HttpField objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course I don't mind. Your C++ is probably better than mine :).
Implement
OPTIONSmethod.When using REST calls using a browser, the
OPTIONScall is made as preflight, before any other calls are done.