Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.61k stars 593 forks source link

Spaces in route parameters #333

Closed jmp0x00 closed 4 years ago

jmp0x00 commented 4 years ago

Describe the bug Spaces in route parameters are encoded as plus signs.

To Reproduce

    @Test
    public void spacesInRouteParamArePercentEncoded() {
        HttpRequest<?> request = Unirest.get("https://en.wikipedia.org/wiki/{pageName}")
                .routeParam("pageName", "Mosaics of Delos");
        System.out.println(request.getUrl());
        Assertions.assertTrue(request.asEmpty().isSuccess());
    }

Expected behavior Spaces in route parameters must be encoded as %20 sequence.

Screenshots Not applicable.

Environmental Data:

Additional context The unirest uses URLEncoder class to encode route parameters, but it should be used for HTML form encoding, not for path encoding.

ryber commented 4 years ago

fixed in 3.4.02