Skip to content

Commit

Permalink
Merge pull request #115 from treeform/guzba
Browse files Browse the repository at this point in the history
2.1.2 updated deps
  • Loading branch information
treeform authored Feb 3, 2024
2 parents ec77b76 + cc292a9 commit b9679ce
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions puppy.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "2.1.1"
version = "2.1.2"
author = "Andre von Houck"
description = "Puppy fetches resources via HTTP and HTTPS."
license = "MIT"
Expand All @@ -8,4 +8,4 @@ srcDir = "src"
requires "nim >= 1.2.2"
requires "libcurl >= 1.0.0"
requires "zippy >= 0.10.0"
requires "webby >= 0.1.6"
requires "webby >= 0.2.0"
8 changes: 6 additions & 2 deletions src/puppy/platforms/linux/platform.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import libcurl, puppy/common, std/strutils, zippy
import libcurl, puppy/common, std/strutils, zippy, webby/httpheaders

block:
## If you did not already call curl_global_init then
Expand Down Expand Up @@ -106,7 +106,11 @@ proc internalFetch*(req: Request): Response {.raises: [PuppyError].} =
for headerLine in headerData.split(CRLF):
let arr = headerLine.split(":", 1)
if arr.len == 2:
result.headers.add((arr[0].strip(), arr[1].strip()))
when (NimMajor, NimMinor, NimPatch) >= (1, 4, 8):
result.headers.add((arr[0].strip(), arr[1].strip()))
else:
let tmp = cast[ptr HttpHeaders](result.headers.addr)
tmp[].toBase.add((arr[0].strip(), arr[1].strip()))

result.body = bodyWrap.str
if result.headers["Content-Encoding"] == "gzip":
Expand Down
6 changes: 4 additions & 2 deletions src/puppy/platforms/macos/platform.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ proc internalFetch*(req: Request): Response {.raises: [PuppyError].} =
let key = keyEnumerator.nextObject
if key.int == 0:
break
let value = dictionary.objectForKey(key)
result.headers.add(($(key.NSString), $(value.NSString)))
let
value = dictionary.objectForKey(key)
tmp = cast[ptr HttpHeaders](result.headers.addr)
tmp[].toBase.add(($(key.NSString), $(value.NSString)))

if data.length > 0:
result.body.setLen(data.length)
Expand Down
9 changes: 5 additions & 4 deletions src/puppy/platforms/win32/platform.nim
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,11 @@ proc internalFetch*(req: Request): Response {.raises: [PuppyError].} =
if line != "":
let parts = line.split(":", 1)
if parts.len == 2:
result.headers.add((
parts[0].strip(),
parts[1].strip()
))
when (NimMajor, NimMinor, NimPatch) >= (1, 4, 8):
result.headers.add((parts[0].strip(), parts[1].strip()))
else:
let tmp = cast[ptr HttpHeaders](result.headers.addr)
tmp[].toBase.add((parts[0].strip(), parts[1].strip()))

var i: int
result.body.setLen(8192)
Expand Down

0 comments on commit b9679ce

Please sign in to comment.