Server must not send `Host` header. (#215)

This commit is contained in:
Eugene Kabanov 2021-08-15 04:29:48 +03:00 committed by GitHub
parent b14f66c295
commit 9d80c7068f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 8 deletions

View File

@ -555,10 +555,7 @@ proc sendErrorResponse(conn: HttpConnectionRef, version: HttpVersion,
else:
answer.add(ConnectionHeader)
answer.add(": close\r\n")
answer.add(HostHeader)
answer.add(": ")
answer.add(conn.server.getHostname())
answer.add("\r\n\r\n")
answer.add("\r\n")
if len(databody) > 0:
answer.add(databody)
try:
@ -1042,8 +1039,6 @@ proc prepareLengthHeaders(resp: HttpResponseRef, length: int): string {.
resp.setHeader(ContentLengthHeader, Base10.toString(uint64(length)))
if not(resp.hasHeader(ServerHeader)):
resp.setHeader(ServerHeader, resp.connection.server.serverIdent)
if not(resp.hasHeader(HostHeader)):
resp.setHeader(HostHeader, resp.connection.server.getHostname())
if not(resp.hasHeader(ConnectionHeader)):
if KeepAlive in resp.flags:
resp.setHeader(ConnectionHeader, "keep-alive")
@ -1069,8 +1064,6 @@ proc prepareChunkedHeaders(resp: HttpResponseRef): string {.
resp.setHeader(TransferEncodingHeader, "chunked")
if not(resp.hasHeader(ServerHeader)):
resp.setHeader(ServerHeader, resp.connection.server.serverIdent)
if not(resp.hasHeader(HostHeader)):
resp.setHeader(HostHeader, resp.connection.server.getHostname())
if not(resp.hasHeader(ConnectionHeader)):
if KeepAlive in resp.flags:
resp.setHeader(ConnectionHeader, "keep-alive")