about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-06-17 16:50:58 +0200
committerbptato <nincsnevem662@gmail.com>2022-06-17 16:50:58 +0200
commit4d2f3c55f7e880814c1d05a6e1137df63374a1b1 (patch)
tree6dfe2e72573f6a246430cddef62fba86eaf9c735
parent692b0bcc108107c191c04a255eeeab237ea5c385 (diff)
downloadchawan-4d2f3c55f7e880814c1d05a6e1137df63374a1b1.tar.gz
Fix curl getting stuck while reading headers
-rw-r--r--src/io/loader.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/io/loader.nim b/src/io/loader.nim
index c4627d56..30ee07e6 100644
--- a/src/io/loader.nim
+++ b/src/io/loader.nim
@@ -144,10 +144,11 @@ proc getPageCurl(loader: FileLoader, url: Url, smethod: HttpMethod = HttpGet, mi
   if not es.atEnd:
     discard es.readLine() # status code
   var headers = newHttpHeaders(true)
-  for line in es.lines:
+  while not es.atEnd:
+    let line = es.readLine()
     let k = line.until(':')
     if k.len == line.len:
-      continue # invalid, no colon
+      break # no colon, invalid or empty - so assume headers are done
     let v = line.substr(k.len + 1).strip()
     headers.add(k, v)
   let ct = headers.getOrDefault("Content-Type")