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

UriComponentsBuilder http/s default port [SPR-15416] #19978

Closed
spring-projects-issues opened this issue Apr 5, 2017 · 2 comments
Closed

UriComponentsBuilder http/s default port [SPR-15416] #19978

spring-projects-issues opened this issue Apr 5, 2017 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

Rico Pahlisch opened SPR-15416 and commented

UriComponentsBuilder returns -1 for http and https urls if there is no port given.

Please change the behaviors to return the default ports for both schemas.

@RunWith(SpringRunner.class)
public class UriComponentsTest {

    @Test
    public void test () throws URISyntaxException {
        UriComponents build = UriComponentsBuilder.fromUri(new URI("http://localhost/")).build();
        assertThat(build.getPort()).isEqualTo(80);
    }
}

No further details from SPR-15416

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

getPort is currently explicitly defined to return -1 if no specific port has been set. In that sense, it allows for differentiating between an explicit port given versus an applicable default port.

Rossen Stoyanchev, what's your take on this?

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Apr 5, 2017

Rossen Stoyanchev commented

Yes allowing to differentiate between explicit vs no port is useful. It's also not an option to assign defaults. There are issues that can arise from such opinionated defaults, see for example #17368.

@spring-projects-issues spring-projects-issues added status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
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: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants