From bbe1a19b6898ce4ab8f7c3a95deaced766a40825 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Sat, 18 Nov 2017 10:56:57 -0500 Subject: [PATCH] better embedded use with outside proxy --- cgi.d | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cgi.d b/cgi.d index 9f78a4c..d26b319 100644 --- a/cgi.d +++ b/cgi.d @@ -1312,7 +1312,7 @@ class Cgi { /** Initializes it from raw HTTP request data. GenericMain uses this when you compile with -version=embedded_httpd. - NOTE: If you are behind a reverse proxy, the values here might not be what you expect.... FIXME somehow. + NOTE: If you are behind a reverse proxy, the values here might not be what you expect.... it will use X-Forwarded-For for remote IP and X-Forwarded-Host for host Params: inputData = the incoming data, including headers and other raw http data. @@ -1478,6 +1478,10 @@ class Cgi { case "content-length": contentLength = to!size_t(value); break; + case "x-forwarded-for": + remoteAddress = value; + break; + case "x-forwarded-host": case "host": host = value; break; @@ -3225,7 +3229,7 @@ class BufferedInputRange { if(ret == Socket.ERROR) { version(Posix) { import core.stdc.errno; - if(errno == EINTR) { + if(errno == EINTR || errno == EAGAIN) { goto try_again; } }