Skip to content

small addons #5847

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

Merged
merged 6 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cores/esp8266/core_esp8266_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#ifndef __CORE_ESP8266_VERSION_H
#define __CORE_ESP8266_VERSION_H

#define HAS_ESP8266_VERSION_NUMERIC 1

#include <core_version.h>

#define __STRHELPER(x) #x
Expand Down Expand Up @@ -52,6 +54,20 @@ extern "C++"
// esp8266CoreVersionSubRevision() is 3 Numeric is: 20499903
// case 2.5.0:
// esp8266CoreVersionSubRevision() is 0 Numeric is: 20500000
//
// Using esp8266::coreVersionNumeric() in a portable way:
//
// #if HAS_ESP8266_VERSION_NUMERIC
// if (esp8266::coreVersionNumeric() >= 20500042)
// {
// // modern api can be used
// }
// else
// #endif
// {
// // code using older api
// // (will not be compiled in when newer api is usable)
// }

namespace conststr {

Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WebServer/src/ESP8266WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ void ESP8266WebServer::_prepareHeader(String& response, int code, const char* co
response = String(F("HTTP/1.")) + String(_currentVersion) + ' ';
response += String(code);
response += ' ';
response += _responseCodeToString(code);
response += responseCodeToString(code);
response += "\r\n";

using namespace mime;
Expand Down Expand Up @@ -625,7 +625,7 @@ void ESP8266WebServer::_finalizeResponse() {
}
}

const String ESP8266WebServer::_responseCodeToString(int code) {
const String ESP8266WebServer::responseCodeToString(const int code) {
switch (code) {
case 100: return F("Continue");
case 101: return F("Switching Protocols");
Expand Down
3 changes: 2 additions & 1 deletion libraries/ESP8266WebServer/src/ESP8266WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class ESP8266WebServer
return _currentClient.write(file);
}

static const String responseCodeToString(const int code);

protected:
virtual size_t _currentClientWrite(const char* b, size_t l) { return _currentClient.write( b, l ); }
virtual size_t _currentClientWrite_P(PGM_P b, size_t l) { return _currentClient.write_P( b, l ); }
Expand All @@ -144,7 +146,6 @@ class ESP8266WebServer
bool _parseRequest(WiFiClient& client);
void _parseArguments(const String& data);
int _parseArgumentsPrivate(const String& data, std::function<void(String&,String&,const String&,int,int,int,int)> handler);
static const String _responseCodeToString(int code);
bool _parseForm(WiFiClient& client, const String& boundary, uint32_t len);
bool _parseFormUploadAborted();
void _uploadWriteByte(uint8_t b);
Expand Down