bnspopi commented on code in PR #74639:
URL: https://github.com/apache/airflow/pull/74639#discussion_r4629238671


##########
providers/http/tests/unit/http/hooks/test_http.py:
##########
@@ -614,9 +614,22 @@ def test_keep_alive_disabled(self):
         [
             pytest.param("https://example.org";, "/v1/test", 
"https://example.org/v1/test";, id="both-set"),
             pytest.param("", "http://foo/bar/v1/test";, 
"http://foo/bar/v1/test";, id="only-endpoint"),
+            pytest.param("https://example.org/v1";, "test", 
"https://example.org/v1/test";, id="no-slash"),
+            pytest.param("https://example.org/v1/";, "test", 
"https://example.org/v1/test";, id="base-slash"),
+            pytest.param(
+                "https://example.org/v1/";, "/test", 
"https://example.org/v1/test";, id="slash-on-both-sides"
+            ),
+            pytest.param(
+                "https://example.org/v1//";, "//test", 
"https://example.org/v1/test";, id="repeated-slashes"
+            ),
+            pytest.param("https://example.org/v1/";, "", 
"https://example.org/v1/";, id="only-base"),
+            pytest.param("https://example.org/v1/";, None, 
"https://example.org/v1/";, id="endpoint-none"),
+            # A connection without a host leaves the authority empty, so the 
base url is the
+            # scheme separator itself and must not be mistaken for a trailing 
path slash.
+            pytest.param("https://";, "/v1/test", "https:///v1/test";, 
id="scheme-only-base"),

Review Comment:
   Yes, it is intentional, but only to keep what `main` does today for that 
input. `_set_base_url` gives `f"{schema}://"` for a connection without a host, 
and on `main` `"https://"; + "/v1/test"` is already `https:///v1/test`, which 
Requests rejects. Without the special case, the new `rstrip('/')` would turn it 
into `https:/v1/test`, a different broken URL, so I left that input alone.
   
   The case that matters for such a connection is the endpoint carrying the 
host: `"https://"; + "example.org/v1/test"` has to stay 
`https://example.org/v1/test`. I added that as a test case in f8dcda94. If you 
would rather have `_url_from_endpoint` raise for a scheme-only base with an 
endpoint that starts with a slash, I can add that, but it felt out of scope for 
the double slash fix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to