Skip to content

Allow ESP8266WebServer::collectHeader to be used from libraries#2475

Open
me-no-dev wants to merge 1 commit intoesp8266:masterfrom
me-no-dev:web-server-collect-headers
Open

Allow ESP8266WebServer::collectHeader to be used from libraries#2475
me-no-dev wants to merge 1 commit intoesp8266:masterfrom
me-no-dev:web-server-collect-headers

Conversation

@me-no-dev
Copy link
Copy Markdown
Collaborator

Move to std::map<String, String>
Connected to: #2225

@codecov-io
Copy link
Copy Markdown

codecov-io commented Sep 2, 2016

Current coverage is 27.80% (diff: 100%)

Merging #2475 into master will not change coverage

@@             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          

Powered by Codecov. Last update 4897e00...33e699c

for (int i = 0; i < _headerKeysCount; ++i) {
_currentHeaders[i].value =String();
}
for (auto& x: _collectedHeaders) {
Copy link
Copy Markdown
Member

@igrr igrr Jan 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of modifying name, i would suggest to specialize map with a custom comparison operator (which would do compareIgnoreCase)

@me-no-dev
Copy link
Copy Markdown
Collaborator Author

wow :D this is so far back I will need a minute to rewind

@earlephilhower earlephilhower added merge-conflict PR has a merge conflict that needs manual correction waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. labels Oct 1, 2019
@earlephilhower
Copy link
Copy Markdown
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflict PR has a merge conflict that needs manual correction waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants