From 293146f2a83aca567d6b39502e054fb745467ffd Mon Sep 17 00:00:00 2001 From: k3-cat Date: Mon, 22 Apr 2024 00:42:03 +1000 Subject: [PATCH] [feat] add a API to get the final url after following redirect responses --- experimental/libbox/http.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/experimental/libbox/http.go b/experimental/libbox/http.go index 87c5bed6..f1fbad58 100644 --- a/experimental/libbox/http.go +++ b/experimental/libbox/http.go @@ -52,6 +52,7 @@ type HTTPRequest interface { type HTTPResponse interface { GetContent() ([]byte, error) GetContentString() (string, error) + GetFinalURL() string WriteTo(path string) error } @@ -233,6 +234,11 @@ func (h *httpResponse) GetContentString() (string, error) { return string(content), nil } +func (h *httpResponse) GetFinalURL() string { + finalURL := h.Request.URL.String() + return finalURL +} + func (h *httpResponse) WriteTo(path string) error { defer h.Body.Close() file, err := os.Create(path)