mirror of
https://github.com/TeamPiped/http3-ytproxy.git
synced 2024-08-14 23:56:43 +00:00
add debug print, skip Authorization header
This commit is contained in:
parent
d99e24abb6
commit
c485587c5c
1 changed files with 8 additions and 3 deletions
11
main.go
11
main.go
|
@ -118,7 +118,6 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
path = strings.Replace(path, "/ggpht", "", 1)
|
path = strings.Replace(path, "/ggpht", "", 1)
|
||||||
path = strings.Replace(path, "/i/", "/", 1)
|
path = strings.Replace(path, "/i/", "/", 1)
|
||||||
|
|
||||||
proxyURL, err := url.Parse("https://" + host + path)
|
proxyURL, err := url.Parse("https://" + host + path)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -131,11 +130,17 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
proxyURL.Path = getBestThumbnail(proxyURL.EscapedPath())
|
proxyURL.Path = getBestThumbnail(proxyURL.EscapedPath())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(proxyURL.String())
|
||||||
|
|
||||||
request, err := http.NewRequest(req.Method, proxyURL.String(), nil)
|
request, err := http.NewRequest(req.Method, proxyURL.String(), nil)
|
||||||
|
|
||||||
copyHeaders(req.Header, request.Header)
|
copyHeaders(req.Header, request.Header)
|
||||||
request.Header.Set("User-Agent", ua)
|
request.Header.Set("User-Agent", ua)
|
||||||
|
|
||||||
|
for name, value := range request.Header {
|
||||||
|
fmt.Printf("%s: %s\n", name, value)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
@ -171,7 +176,7 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
if !strings.HasPrefix(line, "https://") && (strings.HasSuffix(line, ".m3u8") || strings.HasSuffix(line, ".ts")) {
|
if !strings.HasPrefix(line, "https://") && (strings.HasSuffix(line, ".m3u8") || strings.HasSuffix(line, ".ts")) {
|
||||||
path := reqUrl.EscapedPath()
|
path := reqUrl.EscapedPath()
|
||||||
path = path[0 : strings.LastIndex(path, "/")+1]
|
path = path[0 : strings.LastIndex(path, "/")+1]
|
||||||
line = "https://" + reqUrl.Hostname() + path_prefix + path + line
|
line = "https://" + reqUrl.Hostname() + path + line
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(line, "https://") {
|
if strings.HasPrefix(line, "https://") {
|
||||||
lines[i] = RelativeUrl(line)
|
lines[i] = RelativeUrl(line)
|
||||||
|
@ -192,7 +197,7 @@ func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
func copyHeaders(from http.Header, to http.Header) {
|
func copyHeaders(from http.Header, to http.Header) {
|
||||||
// Loop over header names
|
// Loop over header names
|
||||||
for name, values := range from {
|
for name, values := range from {
|
||||||
if name != "Content-Length" && name != "Accept-Encoding" {
|
if name != "Content-Length" && name != "Accept-Encoding" && name != "Authorization" {
|
||||||
// Loop over all values for the name.
|
// Loop over all values for the name.
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
to.Set(name, value)
|
to.Set(name, value)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue