From e655e2c03c36f7763a70cff1cdaadeb6b6c8fbc3 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Tue, 3 Jan 2023 22:08:38 -0600 Subject: [PATCH 1/4] add github token, checkout v3 --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bb27766..4395085 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 From 9a918e32c85daba6aa28879a51946b27e36cc543 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Fri, 6 Jan 2023 23:28:24 -0600 Subject: [PATCH 2/4] do global init --- src/puppy/platforms/linux/platform.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/puppy/platforms/linux/platform.nim b/src/puppy/platforms/linux/platform.nim index 3cc6120..838706b 100644 --- a/src/puppy/platforms/linux/platform.nim +++ b/src/puppy/platforms/linux/platform.nim @@ -1,5 +1,10 @@ import libcurl, puppy/common, std/strutils, zippy +block: + 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. From 59a9cebc64abec35078fab543a68921f153a9b6d Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Fri, 6 Jan 2023 23:58:02 -0600 Subject: [PATCH 3/4] set max redirects --- src/puppy/platforms/linux/platform.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/puppy/platforms/linux/platform.nim b/src/puppy/platforms/linux/platform.nim index 838706b..881f51b 100644 --- a/src/puppy/platforms/linux/platform.nim +++ b/src/puppy/platforms/linux/platform.nim @@ -74,8 +74,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) From ebb0938d1a723655aa35637a5e66d43bcded841e Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Mon, 9 Jan 2023 15:52:54 -0600 Subject: [PATCH 4/4] 2.0.2 --- puppy.nimble | 2 +- src/puppy/platforms/linux/platform.nim | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/puppy.nimble b/puppy.nimble index cc8ceb8..a40ef79 100644 --- a/puppy.nimble +++ b/puppy.nimble @@ -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" diff --git a/src/puppy/platforms/linux/platform.nim b/src/puppy/platforms/linux/platform.nim index 881f51b..b1bd644 100644 --- a/src/puppy/platforms/linux/platform.nim +++ b/src/puppy/platforms/linux/platform.nim @@ -1,6 +1,11 @@ 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))