Skip to content

[tomcat] Spring boot web always return 400 when use a domain name #13236

@ghost

Description

DESKTOP-J5RVINV ~ # curl -v -i 127.0.0.1:8080 -H "Host: domain.sfm"
* Rebuilt URL to: 127.0.0.1:8080/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: domain.sfm
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 200
HTTP/1.1 200
< Content-Type: text/plain;charset=UTF-8
Content-Type: text/plain;charset=UTF-8
< Content-Length: 11
Content-Length: 11
< Date: Wed, 23 May 2018 00:08:51 GMT
Date: Wed, 23 May 2018 00:08:51 GMT

<
* Curl_http_done: called premature == 0
* Connection #0 to host 127.0.0.1 left intact
Hello world#                                                               
DESKTOP-J5RVINV ~ # curl -v -i 127.0.0.1:8080 -H "Host: domain.sf1m"
* Rebuilt URL to: 127.0.0.1:8080/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: domain.sf1m
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 400
HTTP/1.1 400
< Transfer-Encoding: chunked
Transfer-Encoding: chunked
< Date: Wed, 23 May 2018 00:08:55 GMT
Date: Wed, 23 May 2018 00:08:55 GMT
< Connection: close
Connection: close

<
* Curl_http_done: called premature == 0
* Closing connection 0

If the domain .ext contains number, spring boot web always return 400 error code.

My source code

DemoApplication.java

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

HomeController.java

package com.example.demo;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HomeController {
    @GetMapping("/")
    public String home () {
        return "Hello world";
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions