Unverified Commit 38bcf4f9 authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Minor WebServer style/unused var cleanup (#810)

parent 486caf42
...@@ -43,6 +43,7 @@ static const char Content_Length[] = "Content-Length"; ...@@ -43,6 +43,7 @@ static const char Content_Length[] = "Content-Length";
HTTPServer::HTTPServer() HTTPServer::HTTPServer()
: _corsEnabled(false) : _corsEnabled(false)
, _currentClient(nullptr)
, _currentMethod(HTTP_ANY) , _currentMethod(HTTP_ANY)
, _currentVersion(0) , _currentVersion(0)
, _currentStatus(HC_NONE) , _currentStatus(HC_NONE)
...@@ -109,18 +110,15 @@ bool HTTPServer::authenticate(const char * username, const char * password) { ...@@ -109,18 +110,15 @@ bool HTTPServer::authenticate(const char * username, const char * password) {
char toencodeLen = strlen(username) + strlen(password) + 1; char toencodeLen = strlen(username) + strlen(password) + 1;
char *toencode = new char[toencodeLen + 1]; char *toencode = new char[toencodeLen + 1];
if (toencode == NULL) { if (toencode == NULL) {
authReq = "";
return false; return false;
} }
char *encoded = new char[base64_encode_expected_len(toencodeLen) + 1]; char *encoded = new char[base64_encode_expected_len(toencodeLen) + 1];
if (encoded == NULL) { if (encoded == NULL) {
authReq = "";
delete[] toencode; delete[] toencode;
return false; return false;
} }
sprintf(toencode, "%s:%s", username, password); sprintf(toencode, "%s:%s", username, password);
if (base64_encode_chars(toencode, toencodeLen, encoded) > 0 && authReq == encoded) { if (base64_encode_chars(toencode, toencodeLen, encoded) > 0 && authReq == encoded) {
authReq = "";
delete[] toencode; delete[] toencode;
delete[] encoded; delete[] encoded;
return true; return true;
...@@ -132,7 +130,6 @@ bool HTTPServer::authenticate(const char * username, const char * password) { ...@@ -132,7 +130,6 @@ bool HTTPServer::authenticate(const char * username, const char * password) {
log_v("%s", authReq.c_str()); log_v("%s", authReq.c_str());
String _username = _extractParam(authReq, F("username=\""), '\"'); String _username = _extractParam(authReq, F("username=\""), '\"');
if (!_username.length() || _username != String(username)) { if (!_username.length() || _username != String(username)) {
authReq = "";
return false; return false;
} }
// extracting required parameters for RFC 2069 simpler Digest // extracting required parameters for RFC 2069 simpler Digest
...@@ -143,11 +140,9 @@ bool HTTPServer::authenticate(const char * username, const char * password) { ...@@ -143,11 +140,9 @@ bool HTTPServer::authenticate(const char * username, const char * password) {
String _opaque = _extractParam(authReq, F("opaque=\""), '\"'); String _opaque = _extractParam(authReq, F("opaque=\""), '\"');
if ((!_realm.length()) || (!_nonce.length()) || (!_uri.length()) || (!_response.length()) || (!_opaque.length())) { if ((!_realm.length()) || (!_nonce.length()) || (!_uri.length()) || (!_response.length()) || (!_opaque.length())) {
authReq = "";
return false; return false;
} }
if ((_opaque != _sopaque) || (_nonce != _snonce) || (_realm != _srealm)) { if ((_opaque != _sopaque) || (_nonce != _snonce) || (_realm != _srealm)) {
authReq = "";
return false; return false;
} }
// parameters for the RFC 2617 newer Digest // parameters for the RFC 2617 newer Digest
...@@ -179,11 +174,9 @@ bool HTTPServer::authenticate(const char * username, const char * password) { ...@@ -179,11 +174,9 @@ bool HTTPServer::authenticate(const char * username, const char * password) {
} }
log_v("The Proper response=%s", _responsecheck.c_str()); log_v("The Proper response=%s", _responsecheck.c_str());
if (_response == _responsecheck) { if (_response == _responsecheck) {
authReq = "";
return true; return true;
} }
} }
authReq = "";
} }
return false; return false;
} }
...@@ -440,7 +433,7 @@ void HTTPServer::sendContent(const char* content, size_t contentLength) { ...@@ -440,7 +433,7 @@ void HTTPServer::sendContent(const char* content, size_t contentLength) {
const char * footer = "\r\n"; const char * footer = "\r\n";
if (_chunked) { if (_chunked) {
char chunkSize[11]; char chunkSize[11];
sprintf(chunkSize, "%x%s", contentLength, footer); sprintf(chunkSize, "%x%s", (unsigned int)contentLength, footer);
_currentClientWrite(chunkSize, strlen(chunkSize)); _currentClientWrite(chunkSize, strlen(chunkSize));
} }
_currentClientWrite(content, contentLength); _currentClientWrite(content, contentLength);
...@@ -460,7 +453,7 @@ void HTTPServer::sendContent_P(PGM_P content, size_t size) { ...@@ -460,7 +453,7 @@ void HTTPServer::sendContent_P(PGM_P content, size_t size) {
const char * footer = "\r\n"; const char * footer = "\r\n";
if (_chunked) { if (_chunked) {
char chunkSize[11]; char chunkSize[11];
sprintf(chunkSize, "%x%s", size, footer); sprintf(chunkSize, "%x%s", (unsigned int)size, footer);
_currentClientWrite(chunkSize, strlen(chunkSize)); _currentClientWrite(chunkSize, strlen(chunkSize));
} }
_currentClientWrite_P(content, size); _currentClientWrite_P(content, size);
......
...@@ -514,9 +514,8 @@ readfile: ...@@ -514,9 +514,8 @@ readfile:
_uploadWriteByte(0x0A); _uploadWriteByte(0x0A);
_uploadWriteByte((uint8_t)('-')); _uploadWriteByte((uint8_t)('-'));
_uploadWriteByte((uint8_t)('-')); _uploadWriteByte((uint8_t)('-'));
uint32_t j = 0; for (uint32_t j = 0; j < i; j++) {
while (j < i) { _uploadWriteByte(endBuf[j]);
_uploadWriteByte(endBuf[j++]);
} }
goto readfile; goto readfile;
} }
...@@ -545,9 +544,8 @@ readfile: ...@@ -545,9 +544,8 @@ readfile:
_uploadWriteByte(0x0A); _uploadWriteByte(0x0A);
_uploadWriteByte((uint8_t)('-')); _uploadWriteByte((uint8_t)('-'));
_uploadWriteByte((uint8_t)('-')); _uploadWriteByte((uint8_t)('-'));
uint32_t i = 0; for (uint32_t j = 0; j < boundary.length(); j++) {
while (i < boundary.length()) { _uploadWriteByte(endBuf[j]);
_uploadWriteByte(endBuf[i++]);
} }
argByte = _uploadReadByte(client); argByte = _uploadReadByte(client);
goto readfile; goto readfile;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment