Skip to content

Commit

Permalink
Merge pull request #6 from guzba/master
Browse files Browse the repository at this point in the history
1.0.1 string api checks result code
  • Loading branch information
treeform authored Mar 4, 2021
2 parents b14b797 + 92c2f30 commit 286a97b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 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.0"
version = "1.0.1"
author = "Andre von Houck"
description = "Puppy fetches HTML pages for Nim."
license = "MIT"
Expand Down
12 changes: 3 additions & 9 deletions src/puppy.nim
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,11 @@ else:
curl.easy_cleanup()
slist_free_all(headerList)

proc fetch*(url: string, verb = "get"): string =
let req = Request()
req.url = parseUrl(url)
req.verb = verb
let res = req.fetch()
return res.body

proc fetch*(url: string, verb = "get", headers: seq[Header]): string =
proc fetch*(url: string, verb = "get", headers = newSeq[Header]()): string =
let req = Request()
req.url = parseUrl(url)
req.verb = verb
req.headers.merge(headers)
let res = req.fetch()
return res.body
if res.code == 200:
return res.body

0 comments on commit 286a97b

Please sign in to comment.