createRequest improperly combines baseUrl and path
Closed this issue ยท 0 comments
ajcasagrande commented
๐ Bug Report
Affected Services [REQUIRED]
The issue is located in:Is this a regression?
Yes
Description and Minimal Reproduction [REQUIRED]
1450102#diff-0140c618055f750aa9a4d186041e16ad2316f1d47bf2ee16f0810a0489a3c5faR78
๐ฅ Exception or Error
fail to parse baseUrl -> parse \"http://localhost:8080pipelines/status\": invalid port \":8080pipelines\" after host"
Suggested fix:
func createRequestWithEncodedData(ctx context.Context, httpMethod string, baseUrl string, requestPath string, data []byte, encoding string) (*http.Request, errors.EdgeX) {
u, err := parseBaseUrlAndRequestPath(baseUrl, requestPath)
if err != nil {
return nil, errors.NewCommonEdgeX(errors.KindServerError, "failed to parse baseUrl and requestPath", err)
}
func parseBaseUrlAndRequestPath(baseUrl, requestPath string) (*url.URL, error) {
fullPath, err := url.JoinPath(baseUrl, requestPath)
if err != nil {
return nil, err
}
return url.Parse(fullPath)
}
Originally posted by @ajcasagrande in #806 (comment)
๐ Your Environment
Deployment Environment:
EdgeX Version [REQUIRED]:
Anything else relevant?