Use HTTP path prefix of TCP connections to match Docker context behavior

Signed-off-by: Ben Krieger <ben.krieger@intel.com>
This commit is contained in:
Ben Krieger
2024-08-02 10:30:47 -04:00
parent 6011eac97b
commit 6c68f4ad97
2 changed files with 113 additions and 1 deletions

View File

@ -276,7 +276,12 @@ func (c *Connection) DoRequest(ctx context.Context, httpBody io.Reader, httpMeth
params[i+1] = url.PathEscape(pv)
}
uri := fmt.Sprintf("http://d/v%s/libpod"+endpoint, params...)
baseURL := "http://d"
if c.URI.Scheme == "tcp" {
// Allow path prefixes for tcp connections to match Docker behavior
baseURL = "http://" + c.URI.Host + c.URI.Path
}
uri := fmt.Sprintf(baseURL+"/v%s/libpod"+endpoint, params...)
logrus.Debugf("DoRequest Method: %s URI: %v", httpMethod, uri)
req, err := http.NewRequestWithContext(ctx, httpMethod, uri, httpBody)