RFR: 8087112: HTTP API and HTTP/1.1 implementation
Anthony Vanelverdinghe
anthony.vanelverdinghe at gmail.com
Sun Sep 27 08:14:49 UTC 2015
Hi Michael
I forgot to mention that, in Utils.java [1], the exception should also
be thrown in case token is the empty string. And while I'm nitpicking
anyway: here 's an alternative implementation which extracts the
comparison logic in a separate method:
static void validateToken(String token, String errormsg) {
if (token.isEmpty() || token.chars().anyMatch(c -> !isTchar(c))) {
throw new IllegalArgumentException(errormsg);
}
}
private static boolean isTchar(int c) {
return c >= 0x30 && c <= 0x39 // 0 - 9
|| (c >= 0x61 && c <= 0x7a) // a - z
|| (c >= 0x41 && c <= 0x5a) // A - Z
|| (c >= 0x21 && c <= 0x2e && c != 0x22 && c != 0x28 && c
!= 0x29 && c != 0x2c)
|| (c >= 0x5e && c <= 0x60)
|| (c == 0x7c) || (c == 0x7e);
}
PS: I have signed the OCA [2], so you can reuse any code if you wish
[1]
http://cr.openjdk.java.net/~michaelm/8087112/01/src/java.base/share/classes/sun/net/httpclient/Utils.java.html
[2] http://www.oracle.com/technetwork/community/oca-486395.html#v
Kind regards,
Anthony
On 25/09/2015 21:59, Anthony Vanelverdinghe wrote:
> Hi Michael
>
> Maybe these have been fixed in the meantime, but I think I've found a
> bug:
> in
> http://cr.openjdk.java.net/~michaelm/8087112/01/src/java.base/share/classes/sun/net/httpclient/Utils.java.html
> single quotes must be accepted, while parentheses must be rejected [1]
>
> and a few typos:
> in
> http://cr.openjdk.java.net/~michaelm/8087112/01/src/java.base/share/classes/sun/net/httpclient/SSLTunnelConnection.java.html
> at line 56, replace
> return connected & delegate.connected();
> with
> return connected && delegate.connected();
>
> in
> http://cr.openjdk.java.net/~michaelm/8087112/01/src/java.base/share/classes/java/net/package-info.java.udiff.html
> replace "superceded" with "superseded"
>
> On a final note, when will the new API be integrated in the weekly
> early access builds [2]?
>
> [1] https://tools.ietf.org/html/rfc7230#section-3.2.6
> [2] https://jdk9.java.net/download/
>
> Kind regards
> Anthony
>
>
> On 28/08/2015 22:50, Michael McMahon wrote:
>> Hi,
>>
>> I'm looking for reviewers for the http client implementation.
>> This is just the common API layer and the http/1.1 implementation.
>>
>> The webrev is at http://cr.openjdk.java.net/~michaelm/8087112/01/
>>
>> Below is a description of the API classes and the relationship with
>> their implementation classes.
>>
>> Thanks
>> Michael
>>
>>
>> ---------------------------------------------------
>> java.net
>> ---------------------------------------------------
>> HttpClient
>> ||
>> \/
>> Client
>> ||
>> \/
>> sun.net.httpclient.HtpClientImpl
>>
>>
>> HttpRequest
>> ||
>> \/
>> Request
>> ||
>> \/
>> sun.net.httpclient.HtpRequestImpl
>>
>>
>> ----------------------------------------------------------
>> sun.net.httpclient
>> ----------------------------------------------------------
>> Implementation classes showing calling relationship. Classes
>> below have synchronous and asynchronous variants for sending/receiving
>>
>> HttpRequestImpl - overall implementation of HTTP
>> ||
>> \/
>> MultiExchange - manages multiple request/response exchanges that
>> || occur as a result of errors or filters (only used
>> internally)
>> \/
>> Exchange - manages one request response interaction, possibly including
>> || intermediate 100 Continue response.
>> ||
>> \/
>> ExchangeImpl - separates request sending, response receiving. Class is
>> || abstract with different implementations for Http/1 and
>> Http/2
>> \/
>> Http1Exchange - implementation for HTTP/1. Manages TCP connection pools
>> || | HttpConnection (and its subtypes). Interacts with NIO
>> selector
>> || | in HttpClientImpl
>> || +-------+
>> || ||
>> \/ \/
>> Http1Request Http1Response
>>
>>
>> HttpConnection
>> | (subtypes)
>> |
>> PlainHttpConnection
>> PlainProxyConnection
>> PlainTunnelingConnection
>> SSLConnection
>> SSLTunnelingConnection
>>
>> FilterFactory - factory for filters
>> HeaderFilter - internal API for filters (not exposed externally)
>> AuthenticationFilter - implements HTTP Basic auth
>> RedirectionFilter - implements automatic redirection of 3XX responses
>> CookieFilter - implements CookieManager interface
>>
>>
>>
>
>
More information about the net-dev
mailing list