summary refs log tree commit diff stats
path: root/lib/pure/scgi.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-10-13 14:10:33 +0200
committerAraq <rumpf_a@web.de>2015-10-13 14:10:33 +0200
commit8be9e4640320ddc4c11cf433fb6e232a743a9700 (patch)
tree84b223decfbfe5ed5104682dd4fd62a4f274398a /lib/pure/scgi.nim
parent2fda95a4d630aa8b293f16e4f21471f7ee8e743a (diff)
downloadNim-8be9e4640320ddc4c11cf433fb6e232a743a9700.tar.gz
udpated the compiler and tester to use getOrDefault
Diffstat (limited to 'lib/pure/scgi.nim')
-rw-r--r--lib/pure/scgi.nim11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/pure/scgi.nim b/lib/pure/scgi.nim
index 1d54b4591..711e4a897 100644
--- a/lib/pure/scgi.nim
+++ b/lib/pure/scgi.nim
@@ -145,8 +145,8 @@ proc next*(s: var ScgiState, timeout: int = -1): bool =
       L = L * 10 + ord(d) - ord('0')
     recvBuffer(s, L+1)
     s.headers = parseHeaders(s.input, L)
-    if s.headers["SCGI"] != "1": raiseScgiError("SCGI Version 1 expected")
-    L = parseInt(s.headers["CONTENT_LENGTH"])
+    if s.headers.getOrDefault("SCGI") != "1": raiseScgiError("SCGI Version 1 expected")
+    L = parseInt(s.headers.getOrDefault("CONTENT_LENGTH"))
     recvBuffer(s, L)
     return true
 
@@ -221,10 +221,10 @@ proc handleClientRead(client: AsyncClient, s: AsyncScgiState) =
     case ret
     of ReadFullLine:
       client.headers = parseHeaders(client.input, client.input.len-1)
-      if client.headers["SCGI"] != "1": raiseScgiError("SCGI Version 1 expected")
+      if client.headers.getOrDefault("SCGI") != "1": raiseScgiError("SCGI Version 1 expected")
       client.input = "" # For next part
 
-      let contentLen = parseInt(client.headers["CONTENT_LENGTH"])
+      let contentLen = parseInt(client.headers.getOrDefault("CONTENT_LENGTH"))
       if contentLen > 0:
         client.mode = ClientReadContent
       else:
@@ -232,7 +232,8 @@ proc handleClientRead(client: AsyncClient, s: AsyncScgiState) =
         checkCloseSocket(client)
     of ReadPartialLine, ReadDisconnected, ReadNone: return
   of ClientReadContent:
-    let L = parseInt(client.headers["CONTENT_LENGTH"])-client.input.len
+    let L = parseInt(client.headers.getOrDefault("CONTENT_LENGTH")) -
+               client.input.len
     if L > 0:
       let ret = recvBufferAsync(client, L)
       case ret