Skip to content

Conversation

@MarcoPolo
Copy link
Collaborator

The previous version did not correctly handle the case of dot segments in the path. For example if you requested /foo/bar/ and the response Location header redirected you to ../baz, you should go to /foo/baz/.

@MarcoPolo MarcoPolo mentioned this pull request Feb 25, 2025
19 tasks
Comment on lines +530 to +531
locationHeader := resp.Header.Get("Location")
if locationHeader != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, why didn't this work in the previous version where we used
resp.Location
This under the hood resolves the relative path(or at least claims to)
https://github.com/golang/go/blob/master/src/net/http/response.go#L137

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, but it doesn't work with how we encode http paths in the
multiaddr URI. For multiaddr URIs in general we only use URI path components. A relative
URI reference should be relative to the http-path component not the whole
multiaddr. For example multiaddr:/ip4/1.2.3.4/http-path/foo with relative reference /bar
should resolve to multiaddr:/ip4/1.2.3.4/http-path/bar not multiaddr:/bar.

@MarcoPolo MarcoPolo merged commit c250ce3 into master Feb 25, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants