mirror of https://github.com/adamdruppe/arsd.git
http2 cleaner replies, less spam in logs from http2 clients that assume
This commit is contained in:
parent
9dc866b27f
commit
02e0960b7b
24
cgi.d
24
cgi.d
|
@ -1985,6 +1985,12 @@ class Cgi {
|
||||||
if(headerNumber == 1) {
|
if(headerNumber == 1) {
|
||||||
// request line
|
// request line
|
||||||
auto parts = al.splitter(header, " ");
|
auto parts = al.splitter(header, " ");
|
||||||
|
if(parts.front == "PRI") {
|
||||||
|
// this is an HTTP/2.0 line - "PRI * HTTP/2.0" - which indicates their payload will follow
|
||||||
|
// we're going to immediately refuse this, im not interested in implementing http2 (it is unlikely
|
||||||
|
// to bring me benefit)
|
||||||
|
throw new HttpVersionNotSupportedException();
|
||||||
|
}
|
||||||
requestMethod = to!RequestMethod(parts.front);
|
requestMethod = to!RequestMethod(parts.front);
|
||||||
parts.popFront();
|
parts.popFront();
|
||||||
requestUri = parts.front;
|
requestUri = parts.front;
|
||||||
|
@ -3639,8 +3645,8 @@ string plainHttpError(bool isCgi, string type, Throwable t) {
|
||||||
auto message = messageFromException(t);
|
auto message = messageFromException(t);
|
||||||
message = simpleHtmlEncode(message);
|
message = simpleHtmlEncode(message);
|
||||||
|
|
||||||
return format("%s %s\r\nContent-Length: %s\r\n\r\n%s",
|
return format("%s %s\r\nContent-Length: %s\r\nConnection: close\r\n\r\n%s",
|
||||||
isCgi ? "Status:" : "HTTP/1.0",
|
isCgi ? "Status:" : "HTTP/1.1",
|
||||||
type, message.length, message);
|
type, message.length, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4167,6 +4173,10 @@ void serveEmbeddedHttpdProcesses(alias fun, CustomCgi = Cgi)(RequestServer param
|
||||||
if(processPoolSize <= 1)
|
if(processPoolSize <= 1)
|
||||||
closeConnection = true;
|
closeConnection = true;
|
||||||
//cgi = emplace!CustomCgi(cgiContainer, ir, &closeConnection);
|
//cgi = emplace!CustomCgi(cgiContainer, ir, &closeConnection);
|
||||||
|
} catch(HttpVersionNotSupportedException he) {
|
||||||
|
sendAll(ir.source, plainHttpError(false, "505 HTTP Version Not Supported", he));
|
||||||
|
closeConnection = true;
|
||||||
|
break;
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
// a construction error is either bad code or bad request; bad request is what it should be since this is bug free :P
|
// a construction error is either bad code or bad request; bad request is what it should be since this is bug free :P
|
||||||
// anyway let's kill the connection
|
// anyway let's kill the connection
|
||||||
|
@ -4914,6 +4924,10 @@ void doThreadHttpConnectionGuts(CustomCgi, alias fun, bool alwaysCloseConnection
|
||||||
// broken pipe or something, just abort the connection
|
// broken pipe or something, just abort the connection
|
||||||
closeConnection = true;
|
closeConnection = true;
|
||||||
break;
|
break;
|
||||||
|
} catch(HttpVersionNotSupportedException ve) {
|
||||||
|
sendAll(connection, plainHttpError(false, "505 HTTP Version Not Supported", ve));
|
||||||
|
closeConnection = true;
|
||||||
|
break;
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
// a construction error is either bad code or bad request; bad request is what it should be since this is bug free :P
|
// a construction error is either bad code or bad request; bad request is what it should be since this is bug free :P
|
||||||
// anyway let's kill the connection
|
// anyway let's kill the connection
|
||||||
|
@ -5851,6 +5865,12 @@ class ConnectionException : Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class HttpVersionNotSupportedException : Exception {
|
||||||
|
this(string file = __FILE__, size_t line = __LINE__) {
|
||||||
|
super("HTTP Version Not Supported", file, line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
alias void delegate(Socket) CMT;
|
alias void delegate(Socket) CMT;
|
||||||
|
|
||||||
import core.thread;
|
import core.thread;
|
||||||
|
|
Loading…
Reference in New Issue