Skip to content

Commit

Permalink
1.0.3 - fix for VT_EMPTY.
Browse files Browse the repository at this point in the history
  • Loading branch information
treeform committed Mar 5, 2021
1 parent 8561b6f commit 0a4f93e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion puppy.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.0.2"
version = "1.0.3"
author = "Andre von Houck"
description = "Puppy fetches HTML pages for Nim."
license = "MIT"
Expand Down
12 changes: 8 additions & 4 deletions src/puppy.nim
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,15 @@ when defined(windows) and not defined(puppyLibcurl):
result.url = req.url
if result.error.len == 0:
result.code = parseInt(obj.status)
if obj.responseBody != VT_EMPTY:

let isEmpty =
try:
obj.responseBody == VT_EMPTY
except:
false

if not isEmpty:
result.body = string(fromVariant[COMBinary](obj.responseBody))
else:
result.error = "Could not read response body."
return

let headers = $obj.getAllResponseHeaders()
for headerLine in headers.split(CRLF):
Expand Down
12 changes: 12 additions & 0 deletions tests/debug_client.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import puppy

echo repr(fetch("http://localhost:8080/401"))

let res = fetch(Request(
url: parseUrl("http://localhost:8080/401"),
verb: "get"
))
echo "code: ", res.code
echo "headers: ", res.headers
echo "body: ", res.body
echo "error: ", res.error
File renamed without changes.
3 changes: 0 additions & 3 deletions tests/debugpuppy.nim

This file was deleted.

0 comments on commit 0a4f93e

Please sign in to comment.