mirror of https://github.com/adamdruppe/arsd.git
avoid changing the stdout mode unless that function is actually called - no need so do it in a static ctor anyway
This commit is contained in:
parent
48b2516415
commit
d376cc553f
18
cgi.d
18
cgi.d
|
@ -573,14 +573,6 @@ private struct stdin {
|
||||||
import core.sys.windows.windows;
|
import core.sys.windows.windows;
|
||||||
static:
|
static:
|
||||||
|
|
||||||
shared static this() {
|
|
||||||
// Set stdin to binary mode
|
|
||||||
version(Win64)
|
|
||||||
_setmode(std.stdio.stdin.fileno(), 0x8000);
|
|
||||||
else
|
|
||||||
setmode(std.stdio.stdin.fileno(), 0x8000);
|
|
||||||
}
|
|
||||||
|
|
||||||
T[] rawRead(T)(T[] buf) {
|
T[] rawRead(T)(T[] buf) {
|
||||||
uint bytesRead;
|
uint bytesRead;
|
||||||
auto result = ReadFile(GetStdHandle(STD_INPUT_HANDLE), buf.ptr, cast(int) (buf.length * T.sizeof), &bytesRead, null);
|
auto result = ReadFile(GetStdHandle(STD_INPUT_HANDLE), buf.ptr, cast(int) (buf.length * T.sizeof), &bytesRead, null);
|
||||||
|
@ -4044,6 +4036,16 @@ void cgiMainImpl(alias fun, CustomCgi = Cgi, long maxContentLength = defaultMaxC
|
||||||
//version(plain_cgi)
|
//version(plain_cgi)
|
||||||
void handleCgiRequest(alias fun, CustomCgi = Cgi, long maxContentLength = defaultMaxContentLength)() {
|
void handleCgiRequest(alias fun, CustomCgi = Cgi, long maxContentLength = defaultMaxContentLength)() {
|
||||||
// standard CGI is the default version
|
// standard CGI is the default version
|
||||||
|
|
||||||
|
|
||||||
|
// Set stdin to binary mode if necessary to avoid mangled newlines
|
||||||
|
version(Windows) {
|
||||||
|
version(Win64)
|
||||||
|
_setmode(std.stdio.stdin.fileno(), 0x8000);
|
||||||
|
else
|
||||||
|
setmode(std.stdio.stdin.fileno(), 0x8000);
|
||||||
|
}
|
||||||
|
|
||||||
Cgi cgi;
|
Cgi cgi;
|
||||||
try {
|
try {
|
||||||
cgi = new CustomCgi(maxContentLength);
|
cgi = new CustomCgi(maxContentLength);
|
||||||
|
|
Loading…
Reference in New Issue