Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
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
21 changes: 12 additions & 9 deletions 21 WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class WebServer: public Print
{
public:
// passed to a command to indicate what kind of request was received
enum ConnectionType { INVALID, GET, HEAD, POST };
enum ConnectionType { INVALID, GET, HEAD, POST, PUT, DELETE };

// any commands registered with the web server have to follow
// this prototype.
Expand Down Expand Up @@ -214,7 +214,7 @@ class WebServer: public Print

// output headers and a message indicating a server error
void httpFail();

// output headers and a message indicating "401 Unauthorized"
void httpUnauthorized();

Expand Down Expand Up @@ -359,7 +359,7 @@ void WebServer::printP(const prog_uchar *str)
// chunks of 32 bytes to avoid extra short TCP/IP packets
uint8_t buffer[32];
size_t bufferEnd = 0;

while (buffer[bufferEnd++] = pgm_read_byte(str++))
{
if (bufferEnd == 32)
Expand Down Expand Up @@ -791,13 +791,12 @@ bool WebServer::readPOSTparam(char *name, int nameLen,
ch = strtoul(hex, NULL, 16);
}

// check against 1 so we don't overwrite the final NUL
if (nameLen > 1)
if (nameLen > 0)
{
*name++ = ch;
--nameLen;
}
else if (valueLen > 1)
else if (valueLen > 0)
{
*value++ = ch;
--valueLen;
Expand Down Expand Up @@ -951,8 +950,8 @@ URLPARAM_RESULT WebServer::nextURLparam(char **tail, char *name, int nameLen,


// Read and parse the first line of the request header.
// The "command" (GET/HEAD/POST) is translated into a numeric value in type.
// The URL is stored in request, up to the length passed in length
// The "command" (GET/HEAD/POST/PUT/DELETE) is translated into a numeric
// value in type. The URL is stored in request, up to the length passed in length
// NOTE 1: length must include one byte for the terminating NUL.
// NOTE 2: request is NOT checked for NULL, nor length for a value < 1.
// Reading stops when the code encounters a space, CR, or LF. If the HTTP
Expand All @@ -970,13 +969,17 @@ void WebServer::getRequest(WebServer::ConnectionType &type,

type = INVALID;

// store the GET/POST line of the request
// store the GET/POST/PUT/DELETE line of the request
if (expect("GET "))
type = GET;
else if (expect("HEAD "))
type = HEAD;
else if (expect("POST "))
type = POST;
else if (expect("PUT "))
type = PUT;
else if (expect("DELETE "))
type = DELETE;

// if it doesn't start with any of those, we have an unknown method
// so just get out of here
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.