Skip to content

Commit

Permalink
Merge pull request #89 from treeform/guzba
Browse files Browse the repository at this point in the history
1.6.2
  • Loading branch information
treeform authored Dec 10, 2022
2 parents c2cd2c2 + 4bf38aa commit b1388b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ echo res.headers
echo res.body.len
```

# Always use Libcurl
## Always use Libcurl

You can pass `-d:puppyLibcurl` to force use of `libcurl` even on windows and macOS. This is useful to debug, if the some reason native OS API does not work. Libcurl is usually installed on macOS but requires a `curl.dll` on windows.
6 changes: 3 additions & 3 deletions puppy.nimble
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version = "1.6.1"
version = "1.6.2"
author = "Andre von Houck"
description = "Puppy fetches resources via HTTP and HTTPS."
license = "MIT"

srcDir = "src"

requires "nim >= 1.2.2"
requires "urlly >= 1.0.1"
requires "urlly >= 1.1.0"
requires "libcurl >= 1.0.0"
requires "zippy >= 0.9.11"
requires "zippy >= 0.10.0"
7 changes: 4 additions & 3 deletions src/puppy/common.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import strutils, urlly
import std/strutils, urlly

export urlly

Expand All @@ -23,20 +23,21 @@ type
headers*: seq[Header]
code*: int
body*: string

PuppyError* = object of IOError ## Raised if an operation fails.

proc `[]`*(headers: seq[Header], key: string): string =
## Get a key out of headers. Not case sensitive.
## Use a for loop to get multiple keys.
for header in headers:
if header.key.toLowerAscii() == key.toLowerAscii():
if cmpIgnorecase(header.key, key) == 0:
return header.value

proc `[]=`*(headers: var seq[Header], key, value: string) =
## Sets a key in the headers. Not case sensitive.
## If key is not there appends a new key-value pair at the end.
for header in headers.mitems:
if header.key.toLowerAscii() == key.toLowerAscii():
if cmpIgnorecase(header.key, key) == 0:
header.value = value
return
headers.add(Header(key: key, value: value))
Expand Down

0 comments on commit b1388b9

Please sign in to comment.