about summary refs log tree commit diff stats
path: root/adapter/protocol/http.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-04-26 19:20:52 +0200
committerbptato <nincsnevem662@gmail.com>2024-04-26 19:21:35 +0200
commit83dae4a87a78190262317eca15cbb5d25989d41b (patch)
tree3b706bd215e05ef8a07a3f102755a94dff2fe115 /adapter/protocol/http.nim
parent3554f4c3241664d794d656240ccfa43cd99d84df (diff)
downloadchawan-83dae4a87a78190262317eca15cbb5d25989d41b.tar.gz
adapter: update code style
Diffstat (limited to 'adapter/protocol/http.nim')
-rw-r--r--adapter/protocol/http.nim19
1 files changed, 8 insertions, 11 deletions
diff --git a/adapter/protocol/http.nim b/adapter/protocol/http.nim
index e2e53f22..f5e3249c 100644
--- a/adapter/protocol/http.nim
+++ b/adapter/protocol/http.nim
@@ -14,7 +14,7 @@ import utils/twtstr
 
 type
   EarlyHintState = enum
-    NO_EARLY_HINT, EARLY_HINT_STARTED, EARLY_HINT_DONE
+    ehsNone, ehsStarted, ehsDone
 
   HttpHandle = ref object
     curl: CURL
@@ -26,37 +26,34 @@ type
 proc puts(s: string) =
   discard write(1, unsafeAddr s[0], s.len)
 
-proc curlWriteHeader(p: cstring, size, nitems: csize_t, userdata: pointer):
+proc curlWriteHeader(p: cstring; size, nitems: csize_t; userdata: pointer):
     csize_t {.cdecl.} =
   var line = newString(nitems)
   if nitems > 0:
-    prepareMutation(line)
     copyMem(addr line[0], p, nitems)
-
   let op = cast[HttpHandle](userdata)
   if not op.statusline:
     op.statusline = true
     var status: clong
     op.curl.getinfo(CURLINFO_RESPONSE_CODE, addr status)
-    if status == 103 and op.earlyhint == NO_EARLY_HINT:
-      op.earlyhint = EARLY_HINT_STARTED
+    if status == 103 and op.earlyhint == ehsNone:
+      op.earlyhint = ehsStarted
     else:
       op.connectreport = true
       puts("Status: " & $status & "\nCha-Control: ControlDone\n")
     return nitems
-
   if line == "\r\n" or line == "\n":
     # empty line (last, before body)
-    if op.earlyhint == EARLY_HINT_STARTED:
+    if op.earlyhint == ehsStarted:
       # ignore; we do not have a way to stream headers yet.
-      op.earlyhint = EARLY_HINT_DONE
+      op.earlyhint = ehsDone
       # reset statusline; we are awaiting the next line.
       op.statusline = false
       return nitems
     puts("\r\n")
     return nitems
 
-  if op.earlyhint != EARLY_HINT_STARTED:
+  if op.earlyhint != ehsStarted:
     # Regrettably, we can only write early hint headers after the status
     # code is already known.
     # For now, it seems easiest to just ignore them all.
@@ -73,7 +70,7 @@ proc readFromStdin(p: pointer; size, nitems: csize_t; userdata: pointer):
     csize_t {.cdecl.} =
   return csize_t(read(0, p, int(nitems)))
 
-proc curlPreRequest(clientp: pointer, conn_primary_ip, conn_local_ip: cstring,
+proc curlPreRequest(clientp: pointer; conn_primary_ip, conn_local_ip: cstring;
     conn_primary_port, conn_local_port: cint): cint {.cdecl.} =
   let op = cast[HttpHandle](clientp)
   op.connectreport = true