Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Build the URL using url.JoinPath instead of path.Join #249

Merged
merged 4 commits into from
Jun 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions transmission/transmission.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ func (b *batchAgg) fireBatch(events []*Event) {
}
}

url, err := url.Parse(apiHost)
// make sure the api host is valid, if not, error out all the events
_, err := url.Parse(apiHost)
if err != nil {
end := time.Now().UTC()
if b.testNower != nil {
Expand All @@ -421,8 +422,8 @@ func (b *batchAgg) fireBatch(events []*Event) {
return
}

// build the HTTP request
url.Path = buildReqestPath(url.Path, dataset)
// build the HTTP request URL
url := buildReqestPath(apiHost, dataset)
MikeGoldsmith marked this conversation as resolved.
Show resolved Hide resolved

// One retry allowed for connection timeouts.
var resp *http.Response
Expand All @@ -437,9 +438,9 @@ func (b *batchAgg) fireBatch(events []*Event) {
// Pass the underlying bytes.Reader to http.Request so that
// GetBody and ContentLength fields are populated on Request.
// See https://cs.opensource.google/go/go/+/refs/tags/go1.17.5:src/net/http/request.go;l=898
req, err = http.NewRequest("POST", url.String(), &reader.Reader)
req, err = http.NewRequest("POST", url, &reader.Reader)
} else {
req, err = http.NewRequest("POST", url.String(), reqBody)
req, err = http.NewRequest("POST", url, reqBody)
}
req.Header.Set("Content-Type", contentType)
if zipped {
Expand Down Expand Up @@ -743,6 +744,6 @@ type nower interface {
Now() time.Time
}

func buildReqestPath(existingPath, dataset string) string {
return path.Join(existingPath, "/1/batch", url.PathEscape(dataset))
func buildReqestPath(apiHost, dataset string) string {
MikeGoldsmith marked this conversation as resolved.
Show resolved Hide resolved
return path.Join(apiHost, "/1/batch", url.PathEscape(dataset))
}
Loading