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

WebClient ignores port from baseUrl #31315

Closed
watari opened this issue Sep 26, 2023 · 3 comments
Closed

WebClient ignores port from baseUrl #31315

watari opened this issue Sep 26, 2023 · 3 comments
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: duplicate A duplicate of another issue

Comments

@watari
Copy link

watari commented Sep 26, 2023

Affects: 5.3.28 and maybe older versions as well

Steps to reproduce:

  1. Create WebClient instance with baseURL which contains the port (WebClient.builder().baseUrl("localhost:8081")... for example).
  2. Try to make a call to any endpoint on that base URL (webClient.uri("/test-endpoint")... or webClient.uri("test-endpoint")... for example).

Actual behavior:

Request is made to localhost/test-endpoint.

Expected behavior:

Request is made to localhost:8081/test-endpoint.

Such behavior is caused by this check in org.springframework.web.util.HierarchicalUriComponents#copyToUriComponentsBuilder.

Documentation says nothing about this behavior, and it is quite illogical to me.

Is there a way to bypass this problem with current Spring version?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 26, 2023
@watari
Copy link
Author

watari commented Sep 26, 2023

But it works as expected when base URL contains information about protocol (http:///https://)

@sbrannen sbrannen added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Sep 26, 2023
@sbrannen sbrannen changed the title WebClient ignores port from baseUrl WebClient ignores port from baseUrl Sep 26, 2023
@sbrannen
Copy link
Member

I believe the underlying cause is the parsing performed in UriComponentsBuilder.fromUriString(String).

@bclozel
Copy link
Member

bclozel commented Sep 29, 2023

duplicates #31033

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Sep 29, 2023
@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants