mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
[feat] add a API to get the final url after following redirect responses
This commit is contained in:
parent
e80f5ac9dd
commit
293146f2a8
@ -52,6 +52,7 @@ type HTTPRequest interface {
|
|||||||
type HTTPResponse interface {
|
type HTTPResponse interface {
|
||||||
GetContent() ([]byte, error)
|
GetContent() ([]byte, error)
|
||||||
GetContentString() (string, error)
|
GetContentString() (string, error)
|
||||||
|
GetFinalURL() string
|
||||||
WriteTo(path string) error
|
WriteTo(path string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,6 +234,11 @@ func (h *httpResponse) GetContentString() (string, error) {
|
|||||||
return string(content), nil
|
return string(content), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *httpResponse) GetFinalURL() string {
|
||||||
|
finalURL := h.Request.URL.String()
|
||||||
|
return finalURL
|
||||||
|
}
|
||||||
|
|
||||||
func (h *httpResponse) WriteTo(path string) error {
|
func (h *httpResponse) WriteTo(path string) error {
|
||||||
defer h.Body.Close()
|
defer h.Body.Close()
|
||||||
file, err := os.Create(path)
|
file, err := os.Create(path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user