From f191c6f606fe15f2a99b850aabe65c11f884e289 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 13 Dec 2011 21:51:37 -0800 Subject: Better implementation of RFC 2324. --- src/HttpServer.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/HttpServer.cc') diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 1268c7b..a00160f 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -57,6 +57,10 @@ class HttpWorker : public Task { extra.push_back("Allow: GET, POST"); sendError(405, "The HTTP request you've sent contains an unsupported method.", NULL, true, extra, d); } + void send418() { + std::vector d; + sendError(418, "Short and stout. Here is my handle, here is my spout.", NULL, true, d, d); + } void send500(const char * msg, const char * details, std::vector trace) { String smsg; std::vector d; @@ -286,6 +290,9 @@ bool Balau::HttpWorker::handleClient() { } else if ((line[1] == 'U') && (line[2] == 'T') && (line[3] == ' ')) { urlBegin = 4; method = Http::PUT; + } else if ((line[1] == 'R') && (line[2] == 'O') && (line[3] == 'P') && (line[4] == 'F') && (line[5] == 'I') && (line[6] == 'N') && (line[7] == 'D') && (line[8] == ' ')) { + urlBegin = 9; + method = Http::PROPFIND; } break; case 'D': @@ -312,6 +319,18 @@ bool Balau::HttpWorker::handleClient() { method = Http::CONNECT; } break; + case 'B': + if ((line[1] == 'R') && (line[2] == 'E') && (line[3] == 'W') && (line[4] == ' ')) { + urlBegin = 5; + method = Http::BREW; + } + break; + case 'W': + if ((line[1] == 'H') && (line[2] == 'E') && (line[3] == 'N') && (line[4] == ' ')) { + urlBegin = 5; + method = Http::WHEN; + } + break; } if (urlBegin == 0) { Balau::Printer::elog(Balau::E_HTTPSERVER, "%s didn't get a URI after the method", m_name.to_charp()); @@ -380,7 +399,12 @@ bool Balau::HttpWorker::handleClient() { send400(); return false; } - + + if (method == Http::BREW) { + send418(); + return false; + } + if ((method != Http::GET) && (method != Http::POST)) { send405(); return false; -- cgit v1.2.3