Based on the proxy gateway service of dubbo-go, it solves the problem that the external protocol calls the internal Dubbo cluster. At present, it supports HTTP and gRPC[developing].
There are two bugs on HTTP proxy.
[ ] We should reuse http.Client and let user custom it in the config, like MaxIdleConnsPerHost, etc.
[ ] We should close Body so that the connection can be reused.
What happened:
routerfiller.go
req.Header = r.Header
// creat http client too many times
cli := &http3.Client{
Transport: f.transport,
Timeout: hc.Timeout,
}
resp, err := cli.Do(req)
manger.go
func (hcm *HttpConnectionManager) buildTargetResponse(c *pch.HttpContext) {
if c.LocalReply() {
return
}
switch res := c.SourceResp.(type) {
case *stdHttp.Response:
//It is the caller's responsibility to
// close Body. The default HTTP client's Transport may not
// reuse HTTP/1.x "keep-alive" TCP connections if the Body is
// not read to completion and closed.
body, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
//Merge header
remoteHeader := res.Header
for k := range remoteHeader {
c.AddHeader(k, remoteHeader.Get(k))
}
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
There are two bugs on HTTP proxy. [ ] We should reuse http.Client and let user custom it in the config, like MaxIdleConnsPerHost, etc. [ ] We should close Body so that the connection can be reused. What happened: routerfiller.go
manger.go
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?: