-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Build URLs using urljoin #1217
Build URLs using urljoin #1217
Conversation
arg.. CI is failing with this change.. need to investigate when I have a few mins. |
The second assert urljoin("telnet://127.0.0.1", "/") == '/' instead of assert "%s%s" % ("telnet://127.0.0.1", "/") == 'telnet://127.0.0.1/' which changed the failure exception from requests. This is because I suspect Also, I'm suspicious that this is doing the wrong thing anyway, as if the base_url contains a path and does not end in a
I suspect this change will break examples/browse_docs_test.py, for example, due to how urljoin handles absolute paths on the second parameter.
It might be better to just use |
@cgoldberg Looks nice! can you also fix it for FastHttpLocust at the same time? |
@cgoldberg Please see my comment in this PR: |
I agree that we cannot merge this as is. I think that at some point we should deprecate |
I suggest to add ToDo above this code for a future with note something like: "Issue with urljoin, requires refactoring" |
The 'prepending' behaviour documented for this code is much-more similar to how OpenAPI uses "base url", to resolve named APIs, and is probably therefore a less-surprising result. In our case, base_url encapsulates "Some mod_rewrite rule on the firewall, applied to the front of the path in the API documentation". I would normally write any base_url I was discussing to end with |
This PR makes a small change to how URL's are created when a Host is specified. Previously, the URL was built by using string concatenation. This changes it to use
urljoin
.This fixes the edge case where a host is entered containing a trailing slash (i.e.
https://example.com/
rather thanhttps://example.com
). Once merged, it should work with or without trailing a slash.supersedes #1216