mirror of https://github.com/adamdruppe/arsd.git
http chunked spec violations in event source server
amusingly firefox never cared but chrome complains and meh i am legit in the wrong so here we go.
This commit is contained in:
parent
b19526647e
commit
0df59f4b08
14
cgi.d
14
cgi.d
|
@ -5031,6 +5031,7 @@ void sendAll(Socket s, const(void)[] data, string file = __FILE__, size_t line =
|
||||||
throw new ConnectionException(s, lastSocketError, file, line);
|
throw new ConnectionException(s, lastSocketError, file, line);
|
||||||
}
|
}
|
||||||
assert(amount > 0);
|
assert(amount > 0);
|
||||||
|
|
||||||
data = data[amount .. $];
|
data = data[amount .. $];
|
||||||
} while(data.length);
|
} while(data.length);
|
||||||
}
|
}
|
||||||
|
@ -7403,9 +7404,9 @@ final class EventSourceServerImplementation : EventSourceServer, EventIoServer {
|
||||||
foreach(url, connections; eventConnectionsByUrl)
|
foreach(url, connections; eventConnectionsByUrl)
|
||||||
foreach(connection; connections)
|
foreach(connection; connections)
|
||||||
if(connection.needsChunking)
|
if(connection.needsChunking)
|
||||||
nonBlockingWrite(this, connection.fd, "2\r\n:\n");
|
nonBlockingWrite(this, connection.fd, "2\r\n:\n\r\n");
|
||||||
else
|
else
|
||||||
nonBlockingWrite(this, connection.fd, ":\n");
|
nonBlockingWrite(this, connection.fd, ":\n\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void fileClosed(int fd) {
|
void fileClosed(int fd) {
|
||||||
|
@ -7571,20 +7572,23 @@ final class EventSourceServerImplementation : EventSourceServer, EventIoServer {
|
||||||
auto len = toHex(formattedMessage.length);
|
auto len = toHex(formattedMessage.length);
|
||||||
buffer[4 .. 6] = "\r\n"[];
|
buffer[4 .. 6] = "\r\n"[];
|
||||||
buffer[4 - len.length .. 4] = len[];
|
buffer[4 - len.length .. 4] = len[];
|
||||||
|
buffer[6 + formattedMessage.length] = '\r';
|
||||||
|
buffer[6 + formattedMessage.length + 1] = '\n';
|
||||||
|
|
||||||
auto chunkedMessage = buffer[4 - len.length .. 6 + formattedMessage.length];
|
auto chunkedMessage = buffer[4 - len.length .. 6 + formattedMessage.length +2];
|
||||||
// done
|
// done
|
||||||
|
|
||||||
// FIXME: send back requests when needed
|
// FIXME: send back requests when needed
|
||||||
// FIXME: send a single ":\n" every 15 seconds to keep alive
|
// FIXME: send a single ":\n" every 15 seconds to keep alive
|
||||||
|
|
||||||
foreach(connection; connections) {
|
foreach(connection; connections) {
|
||||||
if(connection.needsChunking)
|
if(connection.needsChunking) {
|
||||||
nonBlockingWrite(this, connection.fd, chunkedMessage);
|
nonBlockingWrite(this, connection.fd, chunkedMessage);
|
||||||
else
|
} else {
|
||||||
nonBlockingWrite(this, connection.fd, formattedMessage);
|
nonBlockingWrite(this, connection.fd, formattedMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void runAddonServer(EIS)(string localListenerName, EIS eis) if(is(EIS : EventIoServer)) {
|
void runAddonServer(EIS)(string localListenerName, EIS eis) if(is(EIS : EventIoServer)) {
|
||||||
|
|
Loading…
Reference in New Issue