Kong / unirest-java

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

encoding of the path does not escape spaces #319

Closed Jebusito closed 4 years ago

Jebusito commented 4 years ago

Migrated from a really old Unirest version (1.4.10). On that version, it escaped the spaces as %20, but now it doesn't so it seems like a regression.

Exception given: Caused by: java.net.URISyntaxException: Illegal character in path at index 50: http://192.168.1.13:8000/v1/archivo/demo/expresion interes.pdf

To reproduce GetRequest request = Unirest.get(any given url with a space);

Expected behavior The url should be encoded to http://192.168.1.13:8000/v1/archivo/demo/expresion%20interes.pdf

Environmental Data:

ryber commented 4 years ago

This will be released, probably tomorrow.

note that this is a pretty limited fix for raw paths containing spaces specifically, Now that I think of it I'll go back and add tabs as well, but when dealing with a raw URL at some point it's up to the user to make sure they are passing in a proper URL (technically a URL with a space is not a valid URL). We cannot just url-encode the entire URL because that would itself make it invalid.