[feat] add a API to get the final url after following redirect responses

This commit is contained in:
k3-cat 2024-04-22 00:42:03 +10:00
parent e80f5ac9dd
commit 293146f2a8
No known key found for this signature in database
GPG Key ID: 0F182AF868678A60

View File

@ -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)