example updated

This commit is contained in:
Ryan Oldenburg 2021-03-02 18:12:11 -06:00
parent 51de297036
commit e1d3e697df
1 changed files with 2 additions and 1 deletions

View File

@ -3,7 +3,8 @@ import asyncdispatch, asynchttpserver, zippy
let server = newAsyncHttpServer() let server = newAsyncHttpServer()
proc cb(req: Request) {.async.} = proc cb(req: Request) {.async.} =
if req.headers["Accept-Encoding"].contains("gzip"): if req.headers.hasKey("Accept-Encoding") and
req.headers["Accept-Encoding"].contains("gzip"):
# This client supports gzip, send compressed response # This client supports gzip, send compressed response
let headers = newHttpHeaders([("Content-Encoding", "gzip")]) let headers = newHttpHeaders([("Content-Encoding", "gzip")])
await req.respond( await req.respond(