Allow ESP8266WebServer::collectHeader to be used from libraries#2475
Allow ESP8266WebServer::collectHeader to be used from libraries#2475me-no-dev wants to merge 1 commit intoesp8266:masterfrom
Conversation
Move to std::map<String, String>
Current coverage is 27.80% (diff: 100%)@@ master #2475 diff @@
==========================================
Files 20 20
Lines 3625 3625
Methods 335 335
Messages 0 0
Branches 656 656
==========================================
Hits 1008 1008
Misses 2441 2441
Partials 176 176
|
| for (int i = 0; i < _headerKeysCount; ++i) { | ||
| _currentHeaders[i].value =String(); | ||
| } | ||
| for (auto& x: _collectedHeaders) { |
There was a problem hiding this comment.
this can be replaced with _collectedHeaders.clear();
scratch that; i didn't get that _collectedHeaders is used both as "headers to collect" and "collected headers" at the same time...
| if (i < _headerKeysCount) | ||
| return _currentHeaders[i].value; | ||
| if(i >= 0 && (size_t)i < _collectedHeaders.size()){ | ||
| int n = 0; |
There was a problem hiding this comment.
this is more concisely expressed as
auto it = std::begin(_collectedHeaders);
std::advance(it, i);
return it.second;| for (int i = 0; i < _headerKeysCount; ++i) { | ||
| if (_currentHeaders[i].key.equalsIgnoreCase(name)) | ||
| return _currentHeaders[i].value; | ||
| name.toLowerCase(); |
There was a problem hiding this comment.
instead of modifying name, i would suggest to specialize map with a custom comparison operator (which would do compareIgnoreCase)
|
wow :D this is so far back I will need a minute to rewind |
|
Thanks for your PR, but the core and libraries have changed enough that this PR now has a merge conflict. Could you merge it manually with the latest core, so we can consider it for future releases? |
Move to std::map<String, String>
Connected to: #2225