Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

HttpClient uri 中如果有空格会报错 #66

Closed
venusdrogon opened this issue Jun 26, 2019 · 0 comments
Closed

HttpClient uri 中如果有空格会报错 #66

venusdrogon opened this issue Jun 26, 2019 · 0 comments
Assignees
Milestone

Comments

@venusdrogon
Copy link
Collaborator

venusdrogon commented Jun 26, 2019

    @Test
    public void test(){
        String uri = "https://www.baidu.com/item/BA8 900";
        LOGGER.debug(HttpClientUtil.get(uri));
    }

异常信息

com.feilong.net.UncheckedHttpException: httpRequest:[    {
        "fullEncodedUrl": "https://www.adidas.com.cn/item/BA8 900",
        "requestBody": "",
        "httpMethodType": "GET",
        "paramMap": null,
        "headerMap": null,
        "uri": "https://www.adidas.com.cn/item/BA8 900"
    }],cause by:[java.net.URISyntaxException: Illegal character in path at index 34: https://www.adidas.com.cn/item/BA8 900]
	at com.feilong.net.httpclient4.builder.httpurirequest.URIBuilderBuilder.build(URIBuilderBuilder.java:74)
	at com.feilong.net.httpclient4.builder.httpurirequest.HttpGetBuilder.buildUri(HttpGetBuilder.java:75)
	at com.feilong.net.httpclient4.builder.httpurirequest.HttpGetBuilder.build(HttpGetBuilder.java:58)
	at com.feilong.net.httpclient4.builder.httpurirequest.HttpUriRequestFactory.create(HttpUriRequestFactory.java:60)
	at com.feilong.net.httpclient4.builder.HttpUriRequestBuilder.build(HttpUriRequestBuilder.java:71)
	at com.feilong.net.httpclient4.builder.HttpRequestExecuter.execute(HttpRequestExecuter.java:58)

	at com.feilong.net.httpclient4.HttpClientUtilUriSpaceTest.testGetResponseBodyAsString(HttpClientUtilUriSpaceTest.java:35)

Caused by: java.net.URISyntaxException: Illegal character in path at index 34: https://www.adidas.com.cn/item/BA8 900
	at java.net.URI$Parser.fail(URI.java:2829)
	at java.net.URI$Parser.checkChars(URI.java:3002)
	at java.net.URI$Parser.parseHierarchical(URI.java:3086)
	at java.net.URI$Parser.parse(URI.java:3034)
	at java.net.URI.<init>(URI.java:595)
	at org.apache.http.client.utils.URIBuilder.<init>(URIBuilder.java:83)
	at com.feilong.net.httpclient4.builder.httpurirequest.URIBuilderBuilder.build(URIBuilderBuilder.java:64)
	... 33 more

@venusdrogon venusdrogon added this to the 1.14.0 milestone Jun 26, 2019
@venusdrogon venusdrogon self-assigned this Jun 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant