pipe character support problems
zhangyunhao116 opened this issue · comments
Look like we have not implemented this feature correctly. For example
g.GoBinEnv = append(os.Environ(), "GOPROXY=http://baidu.com|https://goproxy.io")
and curl this link
http://0.0.0.0:8080/github.com/google/go-dap/@v/v0.2.0.mod
we can got an error
github.com/google/go-dap@v0.2.0: malformed record data
The reason is that we skip errors in sumdb_client_ops.go:(sco *sumdbClientOps) load(), this function only called at initialization, but this error occurred in goproxy.go:zipLines, err := g.sumdbClient.Lookup, which called during fetching. Maybe we should skip errors after g.sumdbClient.Lookup?
Go1.15 implements this feature in https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/go/internal/modfetch/proxy.go#L196 may have some help.
Sorry, I don’t think this is our problem, but Baidu's. They returned 200 OK
for all error responses, which is totally wrong.
Try this:
$ curl -LI https://baidu.com/sumdb/sum.golang.org/supported
According this, we need to treat 200 OK
as the expected response. So.
Sure. Baidu in the wrong way, after reading some doc like: https://go.googlesource.com/proposal/+/master/design/25530-sumdb.md#proxying-a-checksum-database , looks like the pipe feature in GOPROXY doesn't provides a fallback for those proxies support checksum database.
Let's makes a simple fake server, which return 200 response in sumdb/sum.golang.org/supported
but return 404 response for others.
fake server:
`package main
import (
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.GET("/sumdb/sum.golang.org/supported", func(c *gin.Context) {
c.Data(200, "text/plain", []byte("ok"))
})
r.Run("0.0.0.0:7070")
}`
Go 1.15 env
go env -w GOPROXY="http://{MY_IP}:7070|http://goproxy.cn"
It can also got an error. Anyway, for now the proxy is consistent with the behavior of Go1.15. Thanks for your quick reply!