summaryrefslogtreecommitdiff
path: root/spartan/client.go
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-08-12 10:47:51 -0600
committertjpcc <tjp@ctrl-c.club>2023-08-12 10:47:51 -0600
commit7d3cbefde656d5520067d56eeb44a8ba1f39d672 (patch)
treef8c12c0cc911cf24743798bbda6f3910f176db1a /spartan/client.go
parent23bc5f4fb7542e64c94eaa7fe2c7a6aa55010898 (diff)
multi-protocol client
Fixes #4
Diffstat (limited to 'spartan/client.go')
-rw-r--r--spartan/client.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/spartan/client.go b/spartan/client.go
index e3025ee..affcf95 100644
--- a/spartan/client.go
+++ b/spartan/client.go
@@ -100,12 +100,12 @@ func (c Client) Fetch(url string) (*types.Response, error) {
if err != nil {
return nil, err
}
- if response.Status != StatusRedirect {
+ if !c.IsRedirect(response) {
return response, nil
}
prev := u
- u, err = neturl.Parse(url)
+ u, err = neturl.Parse(response.Meta.(string))
if err != nil {
return nil, err
}
@@ -115,6 +115,10 @@ func (c Client) Fetch(url string) (*types.Response, error) {
return nil, ExceededMaxRedirects
}
+func (c Client) IsRedirect(response *types.Response) bool {
+ return response.Status == StatusRedirect
+}
+
type devnull struct{}
func (_ devnull) Read(p []byte) (int, error) {