revert query set, remove debug

This commit is contained in:
Andrea Spacca 2021-11-21 21:06:52 +01:00
parent 5e969d3052
commit 01ac42bc11
1 changed files with 2 additions and 11 deletions

13
main.go
View File

@ -117,7 +117,7 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
path := req.URL.EscapedPath()
path = strings.Replace(path, path_prefix, "", 1)
path = strings.Replace(path, "/ggpht", "", 1)
path = strings.Replace(path, "/i/", "/", 1)
@ -127,23 +127,15 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
log.Panic(err)
}
proxyURL.RawQuery = ""
for k, v := range q {
for _, vv := range v {
proxyURL.Query().Set(k, vv)
}
}
proxyURL.RawQuery = q.Encode()
if strings.HasSuffix(proxyURL.EscapedPath(), "maxres.jpg") {
proxyURL.Path = getBestThumbnail(proxyURL.EscapedPath())
}
request, err := http.NewRequest(req.Method, proxyURL.String(), nil)
fmt.Println(proxyURL.Query().Encode())
fmt.Println(proxyURL.String())
copyHeaders(req.Header, request.Header)
request.Header.Set("User-Agent", ua)
fmt.Printf("User-Agent: %s\n", ua)
if err != nil {
log.Panic(err)
@ -205,7 +197,6 @@ func copyHeaders(from http.Header, to http.Header) {
// Loop over all values for the name.
for _, value := range values {
to.Set(name, value)
fmt.Printf("%s: %s\n", name, value)
}
}
}