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

support query strings in checks #1562

Merged
merged 3 commits into from
Aug 12, 2016

Conversation

dbresson
Copy link

resolves #1561

@dbresson dbresson force-pushed the support-query-strings-in-checks branch from ca59e3d to 0d98d36 Compare August 11, 2016 00:57
@diptanu
Copy link
Contributor

diptanu commented Aug 11, 2016

@dbresson I might be wrong, but since you are using Opaque here instead of Path and RawPath and just setting the check.Path, wouldn't the resultant url be something like http://path?

I think we would want this -

url := url.URL{
    Scheme:    check.Protocol,
    Host:       net.JoinHostPort(host, strconv.Itoa(port)),
    Path:        check.Path,
    RawPath:   check.Path,
}

@dbresson
Copy link
Author

I'm pretty sure the hostname and port are not part of the opaque section of a URI. If you're looking at the Go net/url documentation and seeing the opaque example shows the hostname as ignored, that's just because the HTTP request object has Host which overrides the host part of the URL.

@dbresson
Copy link
Author

Ugh, I guess I'm wrong, based on this:
https://golang.org/pkg/net/url/#URL.String

@dbresson
Copy link
Author

It looks like what we really need is URL.parse on the path, and then use URL.ResolveReference to combine the path and query with the rest of the URL.

@diptanu
Copy link
Contributor

diptanu commented Aug 11, 2016

@dbresson What I suggested won't work? From the docs it feels like RawPath which introduced in Go 1.5 is an encoded path hint

@dbresson
Copy link
Author

Well, it might work, but I don't think it's right. It wouldn't set the query component of the URL. It would produce an invalid URL object that just happens to produce the correct URL string.

@diptanu
Copy link
Contributor

diptanu commented Aug 11, 2016

Yeah, if we use RawPath, we would also have to add the RawQuery to add the query parameters.

@dbresson
Copy link
Author

My latest commit is probably closer to something that would work. I don't think it's quite right yet though, I suspect it will break if the path isn't set at all.

}
url := base.ResolveReference(url.parse(check.Path))
Copy link
Contributor

Choose a reason for hiding this comment

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

Parse is an exported method.

@dbresson dbresson force-pushed the support-query-strings-in-checks branch from 55fd622 to e191b0e Compare August 11, 2016 18:28
@dbresson dbresson changed the title switch from Path to Opaque to support query strings support query strings in checks Aug 11, 2016
@dbresson
Copy link
Author

Well, my test seems to pass. I also double checked and path has to have a value for http checks, so there's no problem there. I think the test failures are unrelated to my changes.

@dbresson
Copy link
Author

@diptanu Do you have any further feedback?

@diptanu diptanu merged commit 0d35216 into hashicorp:master Aug 12, 2016
@diptanu
Copy link
Contributor

diptanu commented Aug 12, 2016

@dbresson Thanks! Merged.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP service checks should support query strings
2 participants