hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1682) HttpClient should allow NO port
Date Mon, 31 Aug 2015 07:38:46 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14723120#comment-14723120
] 

Oleg Kalnichevski commented on HTTPCLIENT-1682:
-----------------------------------------------

No, it does not
{code:java}
CloseableHttpClient client = HttpClients.custom().build();
HttpHost target = new HttpHost("rss.cnn.com");
try (CloseableHttpResponse response = client.execute(target, new HttpGet("/rss/edition.rss")))
{
    System.out.println(response.getStatusLine());
    EntityUtils.consume(response.getEntity());
}
{code}

{noformat}
[DEBUG] RequestAddCookies - CookieSpec selected: default
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] PoolingHttpClientConnectionManager - Connection request: [route: {}->http://rss.cnn.com:80][total
kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
[DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://rss.cnn.com:80][total
kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
[DEBUG] MainClientExec - Opening connection {}->http://rss.cnn.com:80
[DEBUG] DefaultHttpClientConnectionOperator - Connecting to rss.cnn.com/107.21.200.223:80
[DEBUG] DefaultHttpClientConnectionOperator - Connection established 10.0.0.8:34977<->107.21.200.223:80
[DEBUG] MainClientExec - Executing request GET /rss/edition.rss HTTP/1.1
[DEBUG] MainClientExec - Target auth state: UNCHALLENGED
[DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED
[DEBUG] headers - http-outgoing-0 >> GET /rss/edition.rss HTTP/1.1
[DEBUG] headers - http-outgoing-0 >> Host: rss.cnn.com
[DEBUG] headers - http-outgoing-0 >> Connection: Keep-Alive
[DEBUG] headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5 (Java/1.7.0_75)
[DEBUG] headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
[DEBUG] headers - http-outgoing-0 << HTTP/1.1 200 OK
[DEBUG] headers - http-outgoing-0 << Content-Length: 6780
[DEBUG] headers - http-outgoing-0 << Content-Encoding: gzip
[DEBUG] headers - http-outgoing-0 << Date: Mon, 31 Aug 2015 07:35:58 GMT
[DEBUG] headers - http-outgoing-0 << Content-Type: text/xml;charset=UTF-8
[DEBUG] headers - http-outgoing-0 << Server: FeedsPortal
[DEBUG] headers - http-outgoing-0 << Set-Cookie: MF2=yx97zdb98ivs; expires=Wed, 30-Aug-17
07:35:58 GMT; path=/
[DEBUG] headers - http-outgoing-0 << ETag: 1441005796000
[DEBUG] headers - http-outgoing-0 << Last-Modified: Mon, 31 Aug 2015 07:23:16 GMT
[DEBUG] headers - http-outgoing-0 << Connection: close
[DEBUG] ResponseProcessCookies - Cookie accepted [MF2="yx97zdb98ivs", version:0, domain:rss.cnn.com,
path:/, expiry:Wed Aug 30 09:35:58 CEST 2017]
[DEBUG] DefaultManagedHttpClientConnection - http-outgoing-0: Shutdown connection
[DEBUG] MainClientExec - Connection discarded
[DEBUG] DefaultManagedHttpClientConnection - http-outgoing-0: Close connection
[DEBUG] PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->http://rss.cnn.com:80][total
kept alive: 0; route allocaHTTP/1.1 200 OK
ted: 0 of 2; total allocated: 0 of 20]
{noformat}

Oleg


> HttpClient should allow NO port
> -------------------------------
>
>                 Key: HTTPCLIENT-1682
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1682
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpClient
>            Reporter: Nathan Hazout
>
> I've noticed that the CNN RSS (rss.cnn.com/rss/edition.rss) worked on some applications
but not on mine.
> Looking deeper, I saw that CNN rejects HTTP requests with
> Host: rss.cnn.com:80
> But accepts requests with
> Host: rss.cnn.com
> Even though 80 is the default port, it only accepts requests with NO port.
> According to the HTTP standards, this is a valid request (even if, granted, strange).
Also, I've noticed that major browsers (tested on chrome) strip out the port from the request
when it is 80.
> However, using HttpClient, setting no port still forces port 80 into the headers.
> Shouldn't HttpClient let the developer set no port all all?
> I'm not saying to automatically strip out the port like Chrome does, but maybe let the
developer decide - if he sets no port, then don't set a port for him automatically?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message