Skip to content

Added HEAD method #3007

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

Closed
wants to merge 4 commits into from
Closed
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
1 change: 1 addition & 0 deletions libraries/ESP8266WebServer/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ hostHeader KEYWORD2

HTTP_GET LITERAL1
HTTP_POST LITERAL1
HTTP_HEAD LITERAL1
HTTP_ANY LITERAL1
CONTENT_LENGTH_UNKNOWN LITERAL1
2 changes: 2 additions & 0 deletions libraries/ESP8266WebServer/src/ESP8266WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ void ESP8266WebServer::send(int code, const String& content_type, const String&
}

void ESP8266WebServer::sendContent(const String& content) {
if(_currentMethod == HTTP_HEAD){ return; }
const char * footer = "\r\n";
size_t len = content.length();
if(_chunked) {
Expand Down Expand Up @@ -661,6 +662,7 @@ const String ESP8266WebServer::responseCodeToString(const int code) {
case 415: return F("Unsupported Media Type");
case 416: return F("Requested range not satisfiable");
case 417: return F("Expectation Failed");
case 418: return F("I'm a teapot");
case 500: return F("Internal Server Error");
case 501: return F("Not Implemented");
case 502: return F("Bad Gateway");
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WebServer/src/ESP8266WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <memory>
#include <ESP8266WiFi.h>

enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };
enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS, HTTP_HEAD };
enum HTTPUploadStatus { UPLOAD_FILE_START, UPLOAD_FILE_WRITE, UPLOAD_FILE_END,
UPLOAD_FILE_ABORTED };
enum HTTPClientStatus { HC_NONE, HC_WAIT_READ, HC_WAIT_CLOSE };
Expand Down
2 changes: 2 additions & 0 deletions libraries/ESP8266WebServer/src/Parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ bool ESP8266WebServer::_parseRequest(WiFiClient& client) {
method = HTTP_PUT;
} else if (methodStr == F("PATCH")) {
method = HTTP_PATCH;
} else if (methodStr == "HEAD") {
method = HTTP_HEAD;
}
_currentMethod = method;

Expand Down