Skip to content

Commit

Permalink
Merge pull request #94 from treeform/guzba
Browse files Browse the repository at this point in the history
add github token, checkout v3, global init
  • Loading branch information
treeform authored Jan 10, 2023
2 parents 44d93ad + ebb0938 commit affc4b2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: jiro4989/setup-nim-action@v1
with:
nim-version: ${{ matrix.nim-version }}
repo-token: ${{ secrets.GITHUB_TOKEN }}

- run: nimble install -y libcurl
- run: nimble install -y zippy
Expand Down
2 changes: 1 addition & 1 deletion puppy.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "2.0.1"
version = "2.0.2"
author = "Andre von Houck"
description = "Puppy fetches resources via HTTP and HTTPS."
license = "MIT"
Expand Down
14 changes: 13 additions & 1 deletion src/puppy/platforms/linux/platform.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import libcurl, puppy/common, std/strutils, zippy

block:
## If you did not already call curl_global_init then
## curl_easy_init does it automatically.
## This may be lethal in multi-threaded cases since curl_global_init
## is not thread-safe.
## https://curl.se/libcurl/c/curl_easy_init.html
let ret = global_init(GLOBAL_DEFAULT)
if ret != E_OK:
raise newException(Defect, $easy_strerror(ret))

type StringWrap = object
## As strings are value objects they need
## some sort of wrapper to be passed to C.
Expand Down Expand Up @@ -69,8 +79,10 @@ proc fetch*(req: Request): Response {.raises: [PuppyError].} =
# On Windows look for cacert.pem.
when defined(windows):
discard curl.easy_setopt(OPT_CAINFO, "cacert.pem".cstring)
# Follow redirects by default.

# Follow up to 10 redirects by default.
discard curl.easy_setopt(OPT_FOLLOWLOCATION, 1)
discard curl.easy_setopt(OPT_MAXREDIRS, 10)

if req.allowAnyHttpsCertificate:
discard curl.easy_setopt(OPT_SSL_VERIFYPEER, 0)
Expand Down

0 comments on commit affc4b2

Please sign in to comment.