Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.1.2 updated deps #115

Merged
merged 4 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading