Open
Conversation
QuickSander
requested changes
Nov 29, 2022
| void ArduinoHttpServer::AbstractStreamHttpReply::addHeader(const String& name, const String &value) { | ||
| if (m_headerCount == MAX_HEADERS) return; | ||
|
|
||
| m_headerNames[m_headerCount] = name; |
Owner
There was a problem hiding this comment.
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 |
Owner
There was a problem hiding this comment.
Suggested change
| // len("OPTIONS") + 1 for terminating null = 7 | |
| // len("OPTIONS") + 1 for terminating null = 8 |
|
|
||
| #include "ArduinoHttpServerDebug.h" | ||
|
|
||
| #define MAX_HEADERS 3 |
Owner
There was a problem hiding this comment.
Can you change it to modern C++ typesafe constexpr?
Author
There was a problem hiding this comment.
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]; |
Owner
There was a problem hiding this comment.
If you don't mind, I think I will rewrite it to become an array of HttpField objects.
Author
There was a problem hiding this comment.
Of course I don't mind. Your C++ is probably better than mine :).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement
OPTIONSmethod.When using REST calls using a browser, the
OPTIONScall is made as preflight, before any other calls are done.