From 772f92037f6536f85d66e7cb86521e64e7241a46 Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Mon, 2 Oct 2023 18:24:46 +0200 Subject: [PATCH] Return redirect count in response object --- README.org | 1 + curl.bqn | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index bba8bbc..fa2ff07 100644 --- a/README.org +++ b/README.org @@ -41,6 +41,7 @@ The response object is a namespace with the following elements: - ~headers~: the response headers as a single string, separated by newlines. - ~content~: the response content, as raw bytes. - ~time~: the time the request took, in seconds. +- ~redirectCount~: the number of redirects. If your endpoint returns text, you can use ~FromBytes~ from [[https://github.com/mlochbaum/bqn-libs/blob/master/strings.bqn][bqn-libs/strings.bqn]] to decode UTF-8. diff --git a/curl.bqn b/curl.bqn index 4bd3b30..4533f00 100644 --- a/curl.bqn +++ b/curl.bqn @@ -135,6 +135,8 @@ Perform←{𝕊 session: rcode‿⟨code⟩←EasyGetinfoLong⟨session.sessionPtr,curlInfo.responseCode,⟨0⟩⟩ "retrieving response code"Check rcode + rredirectcount‿⟨redirectCount⟩←EasyGetinfoLong⟨session.sessionPtr,curlInfo.redirectCount,⟨0⟩⟩ + "retrieving redirect count"Check rredirectcount rtime‿⟨time⟩←EasyGetinfoDouble⟨session.sessionPtr,curlInfo.totalTime,⟨0.0⟩⟩ "retrieving request time"Check rtime @@ -149,8 +151,9 @@ Perform←{𝕊 session: { code⇐code, - time⇐time, headers⇐responseHeaders, content⇐content, + time⇐time, + redirectCount⇐redirectCount, } }