changeset 16234:3b25414eb6af

8170648: Move java.net.http package out of Java SE to incubator namespace Reviewed-by: chegar, dfuchs, michaelm, prappo, skuksenko Contributed-by: Chris Hegarty <chris.hegarty@oracle.com>, Daniel Fuchs <daniel.fuchs@oracle.com>, Michael McMahon <michael.x.mcmahon@oracle.com>, Pavel Rappo <pavel.rappo@oracle.com>, Sergey Kuksenko <sergey.kuksenko@oracle.com>, anthony.vanelverdinghe@gmail.com
author michaelm
date Fri, 09 Dec 2016 11:35:02 +0000
parents f418bde7bcf1
children d5fae1e4ae74
files src/java.base/share/classes/module-info.java src/java.base/share/lib/security/default.policy src/java.httpclient/share/classes/java/net/http/AsyncConnection.java src/java.httpclient/share/classes/java/net/http/AsyncEvent.java src/java.httpclient/share/classes/java/net/http/AsyncSSLConnection.java src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java src/java.httpclient/share/classes/java/net/http/AuthenticationFilter.java src/java.httpclient/share/classes/java/net/http/BufferHandler.java src/java.httpclient/share/classes/java/net/http/ByteBufferConsumer.java src/java.httpclient/share/classes/java/net/http/ByteBufferGenerator.java src/java.httpclient/share/classes/java/net/http/CharsetToolkit.java src/java.httpclient/share/classes/java/net/http/ConnectionPool.java src/java.httpclient/share/classes/java/net/http/ContinuationFrame.java src/java.httpclient/share/classes/java/net/http/CookieFilter.java src/java.httpclient/share/classes/java/net/http/DataFrame.java src/java.httpclient/share/classes/java/net/http/ErrorFrame.java src/java.httpclient/share/classes/java/net/http/Exchange.java src/java.httpclient/share/classes/java/net/http/ExchangeImpl.java src/java.httpclient/share/classes/java/net/http/ExecutorWrapper.java src/java.httpclient/share/classes/java/net/http/FilterFactory.java src/java.httpclient/share/classes/java/net/http/FrameReader.java src/java.httpclient/share/classes/java/net/http/GoAwayFrame.java src/java.httpclient/share/classes/java/net/http/HeaderFilter.java src/java.httpclient/share/classes/java/net/http/HeaderFrame.java src/java.httpclient/share/classes/java/net/http/HeaderParser.java src/java.httpclient/share/classes/java/net/http/HeadersFrame.java src/java.httpclient/share/classes/java/net/http/Http1Exchange.java src/java.httpclient/share/classes/java/net/http/Http1Request.java src/java.httpclient/share/classes/java/net/http/Http1Response.java src/java.httpclient/share/classes/java/net/http/Http2ClientImpl.java src/java.httpclient/share/classes/java/net/http/Http2Connection.java src/java.httpclient/share/classes/java/net/http/Http2Frame.java src/java.httpclient/share/classes/java/net/http/HttpClient.java src/java.httpclient/share/classes/java/net/http/HttpClientBuilderImpl.java src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java src/java.httpclient/share/classes/java/net/http/HttpConnection.java src/java.httpclient/share/classes/java/net/http/HttpHeaders.java src/java.httpclient/share/classes/java/net/http/HttpHeadersImpl.java src/java.httpclient/share/classes/java/net/http/HttpRedirectImpl.java src/java.httpclient/share/classes/java/net/http/HttpRequest.java src/java.httpclient/share/classes/java/net/http/HttpRequestBuilderImpl.java src/java.httpclient/share/classes/java/net/http/HttpRequestImpl.java src/java.httpclient/share/classes/java/net/http/HttpResponse.java src/java.httpclient/share/classes/java/net/http/HttpResponseImpl.java src/java.httpclient/share/classes/java/net/http/HttpTimeoutException.java src/java.httpclient/share/classes/java/net/http/ImmutableHeaders.java src/java.httpclient/share/classes/java/net/http/Log.java src/java.httpclient/share/classes/java/net/http/MultiExchange.java src/java.httpclient/share/classes/java/net/http/OutgoingHeaders.java src/java.httpclient/share/classes/java/net/http/Pair.java src/java.httpclient/share/classes/java/net/http/PingFrame.java src/java.httpclient/share/classes/java/net/http/PlainHttpConnection.java src/java.httpclient/share/classes/java/net/http/PlainProxyConnection.java src/java.httpclient/share/classes/java/net/http/PlainTunnelingConnection.java src/java.httpclient/share/classes/java/net/http/PriorityFrame.java src/java.httpclient/share/classes/java/net/http/PushPromiseFrame.java src/java.httpclient/share/classes/java/net/http/Queue.java src/java.httpclient/share/classes/java/net/http/RawChannel.java src/java.httpclient/share/classes/java/net/http/RawChannelImpl.java src/java.httpclient/share/classes/java/net/http/RedirectFilter.java src/java.httpclient/share/classes/java/net/http/ResetFrame.java src/java.httpclient/share/classes/java/net/http/ResponseContent.java src/java.httpclient/share/classes/java/net/http/ResponseHeaders.java src/java.httpclient/share/classes/java/net/http/SSLConnection.java src/java.httpclient/share/classes/java/net/http/SSLDelegate.java src/java.httpclient/share/classes/java/net/http/SSLTunnelConnection.java src/java.httpclient/share/classes/java/net/http/SettingsFrame.java src/java.httpclient/share/classes/java/net/http/Stream.java src/java.httpclient/share/classes/java/net/http/TimeoutEvent.java src/java.httpclient/share/classes/java/net/http/Utils.java src/java.httpclient/share/classes/java/net/http/WS.java src/java.httpclient/share/classes/java/net/http/WSBuilder.java src/java.httpclient/share/classes/java/net/http/WSCharsetToolkit.java src/java.httpclient/share/classes/java/net/http/WSDisposable.java src/java.httpclient/share/classes/java/net/http/WSFrame.java src/java.httpclient/share/classes/java/net/http/WSFrameConsumer.java src/java.httpclient/share/classes/java/net/http/WSMessageConsumer.java src/java.httpclient/share/classes/java/net/http/WSMessageSender.java src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java src/java.httpclient/share/classes/java/net/http/WSOutgoingMessage.java src/java.httpclient/share/classes/java/net/http/WSProtocolException.java src/java.httpclient/share/classes/java/net/http/WSReceiver.java src/java.httpclient/share/classes/java/net/http/WSShared.java src/java.httpclient/share/classes/java/net/http/WSSharedPool.java src/java.httpclient/share/classes/java/net/http/WSSignalHandler.java src/java.httpclient/share/classes/java/net/http/WSTransmitter.java src/java.httpclient/share/classes/java/net/http/WSUtils.java src/java.httpclient/share/classes/java/net/http/WSWriter.java src/java.httpclient/share/classes/java/net/http/WebSocket.java src/java.httpclient/share/classes/java/net/http/WebSocketHandshakeException.java src/java.httpclient/share/classes/java/net/http/WindowUpdateFrame.java src/java.httpclient/share/classes/java/net/http/package-info.java src/java.httpclient/share/classes/module-info.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/BinaryRepresentationWriter.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/BulkSizeUpdateWriter.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/Decoder.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/DecodingCallback.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/Encoder.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/HeaderTable.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/Huffman.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/ISO_8859_1.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/IndexNameValueWriter.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/IndexedWriter.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/IntegerReader.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/IntegerWriter.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/LiteralNeverIndexedWriter.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/LiteralWithIndexingWriter.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/LiteralWriter.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/SizeUpdateWriter.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/StringReader.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/StringWriter.java src/java.httpclient/share/classes/sun/net/httpclient/hpack/package-info.java src/java.se/share/classes/module-info.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AbstractPushPublisher.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AsyncConnection.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AsyncEvent.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AsyncSSLConnection.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AsyncSSLDelegate.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AuthenticationFilter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/BlockingPushPublisher.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ConnectionPool.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/CookieFilter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/DefaultPublisher.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Exchange.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ExchangeImpl.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ExecutorWrapper.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/FilterFactory.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HeaderFilter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HeaderParser.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Exchange.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Request.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http1Response.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2ClientImpl.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClient.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientBuilderImpl.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpConnection.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpHeaders.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequest.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequestBuilderImpl.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequestImpl.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpResponse.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpResponseImpl.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpTimeoutException.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ImmutableHeaders.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/MultiExchange.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/MultiMapResult.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainProxyConnection.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainTunnelingConnection.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PseudoPublisher.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PullPublisher.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PushGroup.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PushPublisher.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RawChannelImpl.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RedirectFilter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RequestProcessors.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Response.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ResponseContent.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ResponseHeaders.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ResponseProcessors.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/SSLConnection.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/SSLDelegate.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/SSLTunnelConnection.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Stream.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/TimeoutEvent.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WebSocket.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WebSocketHandshakeException.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WindowController.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WindowUpdateSender.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/AsyncWriteQueue.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/BufferHandler.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/ByteBufferPool.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/ByteBufferReference.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/ExceptionallyCloseable.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/HttpHeadersImpl.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Log.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/MinimalFuture.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Pair.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Queue.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Utils.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/ContinuationFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/DataFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/ErrorFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/FramesDecoder.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/FramesEncoder.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/GoAwayFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/HeaderFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/HeadersFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/Http2Frame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/MalformedFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/OutgoingHeaders.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/PingFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/PriorityFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/PushPromiseFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/ResetFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/SettingsFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/WindowUpdateFrame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/BinaryRepresentationWriter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/BulkSizeUpdateWriter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/Decoder.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/DecodingCallback.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/Encoder.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/HeaderTable.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/Huffman.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/ISO_8859_1.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/IndexNameValueWriter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/IndexedWriter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/IntegerReader.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/IntegerWriter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/LiteralNeverIndexedWriter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/LiteralWithIndexingWriter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/LiteralWriter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/SizeUpdateWriter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/StringReader.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/StringWriter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/package-info.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/BuilderImpl.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/CheckFailedException.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/CooperativeHandler.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/FailWebSocketException.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/Frame.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/FrameConsumer.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/MessageStreamConsumer.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/OpeningHandshake.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/OutgoingMessage.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/RawChannel.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/Receiver.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/StatusCodes.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/Transmitter.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/UTF8AccumulatingDecoder.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/WebSocketImpl.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/WebSocketRequest.java src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/package-info.java src/jdk.incubator.httpclient/share/classes/module-info.java test/ProblemList.txt test/TEST.groups test/java/net/httpclient/APIErrors.java test/java/net/httpclient/BasicAuthTest.java test/java/net/httpclient/BasicWebSocketAPITest.java test/java/net/httpclient/EchoHandler.java test/java/net/httpclient/HeadersTest.java test/java/net/httpclient/HeadersTest1.java test/java/net/httpclient/HttpInputStreamTest.java test/java/net/httpclient/HttpRequestBuilderTest.java test/java/net/httpclient/HttpUtils.java test/java/net/httpclient/ImmutableHeaders.java test/java/net/httpclient/ManyRequests.java test/java/net/httpclient/MessageHeadersTest.java test/java/net/httpclient/MultiAuthTest.java test/java/net/httpclient/ProxyAuthTest.java test/java/net/httpclient/QuickResponses.java test/java/net/httpclient/RequestBodyTest.java test/java/net/httpclient/Server.java test/java/net/httpclient/ShortRequestBody.java test/java/net/httpclient/SmokeTest.java test/java/net/httpclient/SplitResponse.java test/java/net/httpclient/TEST.properties test/java/net/httpclient/TestKit.java test/java/net/httpclient/TestKitTest.java test/java/net/httpclient/TimeoutBasic.java test/java/net/httpclient/TimeoutOrdering.java test/java/net/httpclient/TimeoutTest.java test/java/net/httpclient/examples/WebSocketExample.java test/java/net/httpclient/http2/BasicTest.java test/java/net/httpclient/http2/ErrorTest.java test/java/net/httpclient/http2/HpackDriver.java test/java/net/httpclient/http2/HpackDriverHeaderTable.java test/java/net/httpclient/http2/NoBody.java test/java/net/httpclient/http2/RedirectTest.java test/java/net/httpclient/http2/ServerPush.java test/java/net/httpclient/http2/TEST.properties test/java/net/httpclient/http2/TLSConnection.java test/java/net/httpclient/http2/Timeout.java test/java/net/httpclient/http2/java.httpclient/java/net/http/BodyInputStream.java test/java/net/httpclient/http2/java.httpclient/java/net/http/BodyOutputStream.java test/java/net/httpclient/http2/java.httpclient/java/net/http/EchoHandler.java test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2Handler.java test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestExchange.java test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServer.java test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServerConnection.java test/java/net/httpclient/http2/java.httpclient/java/net/http/OutgoingPushPromise.java test/java/net/httpclient/http2/java.httpclient/java/net/http/PushHandler.java test/java/net/httpclient/http2/java.httpclient/java/net/http/TestUtil.java test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/BinaryPrimitivesTest.java test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/BuffersTestingKit.java test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/CircularBufferTest.java test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/DecoderTest.java test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/EncoderTest.java test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/HeaderTableTest.java test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/HuffmanTest.java test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/SpecHelper.java test/java/net/httpclient/http2/java.httpclient/sun/net/httpclient/hpack/TestHelper.java test/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/BinaryPrimitivesTest.java test/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/BuffersTestingKit.java test/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/CircularBufferTest.java test/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/DecoderTest.java test/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/EncoderTest.java test/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/HeaderTableTest.java test/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/HuffmanTest.java test/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/SpecHelper.java test/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/TestHelper.java test/java/net/httpclient/http2/server/BodyInputStream.java test/java/net/httpclient/http2/server/BodyOutputStream.java test/java/net/httpclient/http2/server/EchoHandler.java test/java/net/httpclient/http2/server/Http2Handler.java test/java/net/httpclient/http2/server/Http2TestExchange.java test/java/net/httpclient/http2/server/Http2TestServer.java test/java/net/httpclient/http2/server/Http2TestServerConnection.java test/java/net/httpclient/http2/server/NoBodyHandler.java test/java/net/httpclient/http2/server/OutgoingPushPromise.java test/java/net/httpclient/http2/server/PushHandler.java test/java/net/httpclient/http2/server/RedirectHandler.java test/java/net/httpclient/http2/server/TestUtil.java test/java/net/httpclient/security/0.policy test/java/net/httpclient/security/1.policy test/java/net/httpclient/security/10.policy test/java/net/httpclient/security/11.policy test/java/net/httpclient/security/12.policy test/java/net/httpclient/security/14.policy test/java/net/httpclient/security/15.policy test/java/net/httpclient/security/2.policy test/java/net/httpclient/security/3.policy test/java/net/httpclient/security/4.policy test/java/net/httpclient/security/5.policy test/java/net/httpclient/security/6.policy test/java/net/httpclient/security/7.policy test/java/net/httpclient/security/8.policy test/java/net/httpclient/security/9.policy test/java/net/httpclient/security/Driver.java test/java/net/httpclient/security/Security.java test/java/net/httpclient/websocket/WSDriver.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/BuildingWebSocketTest.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/CloseTest.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/DataProviders.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/HeaderWriterTest.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/MaskerTest.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/MockChannel.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/MockChannelTest.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/MockListener.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/MockListenerTest.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/PingTest.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/ReaderTest.java test/java/net/httpclient/websocket/jdk.incubator.httpclient/jdk/incubator/http/internal/websocket/TestSupport.java test/java/net/httpclient/whitebox/Driver.java test/java/net/httpclient/whitebox/java.httpclient/java/net/http/SelectorTest.java test/java/net/httpclient/whitebox/jdk.incubator.httpclient/jdk/incubator/http/ResponseHeadersTest.java test/java/net/httpclient/whitebox/jdk.incubator.httpclient/jdk/incubator/http/SelectorTest.java
diffstat 349 files changed, 37284 insertions(+), 30332 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/module-info.java	Fri Dec 09 17:01:03 2016 +0530
+++ b/src/java.base/share/classes/module-info.java	Fri Dec 09 11:35:02 2016 +0000
@@ -156,6 +156,7 @@
     exports jdk.internal.misc to
         java.corba,
         java.desktop,
+        jdk.incubator.httpclient,
         java.logging,
         java.management,
         java.naming,
@@ -199,7 +200,7 @@
         java.management,
         jdk.jvmstat;
     exports sun.net to
-        java.httpclient;
+        jdk.incubator.httpclient;
     exports sun.net.ext to
         jdk.net;
     exports sun.net.dns to
@@ -210,6 +211,7 @@
         jdk.jconsole,
         jdk.naming.dns;
     exports sun.net.www to
+        jdk.incubator.httpclient,
         java.desktop,
         jdk.jartool;
     exports sun.net.www.protocol.http to
--- a/src/java.base/share/lib/security/default.policy	Fri Dec 09 17:01:03 2016 +0530
+++ b/src/java.base/share/lib/security/default.policy	Fri Dec 09 11:35:02 2016 +0000
@@ -20,6 +20,9 @@
     permission java.security.AllPermission;
 };
 
+grant codeBase "jrt:/jdk.incubator.httpclient" {
+};
+
 grant codeBase "jrt:/java.scripting" {
     permission java.security.AllPermission;
 };
--- a/src/java.httpclient/share/classes/java/net/http/AsyncConnection.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.nio.ByteBuffer;
-import java.util.function.Consumer;
-
-/**
- * Implemented by classes that offer an asynchronous interface.
- *
- * PlainHttpConnection, AsyncSSLConnection AsyncSSLDelegate.
- *
- * setAsyncCallbacks() is called to set the callback for reading
- * and error notification. Reads all happen on the selector thread, which
- * must not block.
- *
- * Writing uses the same write() methods as used in blocking mode.
- * Queues are employed on the writing side to buffer data while it is waiting
- * to be sent. This strategy relies on HTTP/2 protocol flow control to stop
- * outgoing queue from continually growing. Writes can be initiated by the
- * calling thread, but if socket becomes full then the queue is emptied by
- * the selector thread
- *
- */
-interface AsyncConnection {
-
-    /**
-     * Enables asynchronous sending and receiving mode. The given async
-     * receiver will receive all incoming data. asyncInput() will be called
-     * to trigger reads. asyncOutput() will be called to drive writes.
-     *
-     * The errorReceiver callback must be called when any fatal exception
-     * occurs. Connection is assumed to be closed afterwards.
-     *
-     * @param asyncReceiver
-     * @param errorReceiver
-     */
-    void setAsyncCallbacks(
-            Consumer<ByteBuffer> asyncReceiver,
-            Consumer<Throwable> errorReceiver);
-
-    /**
-     * Does whatever is required to start reading. Usually registers
-     * an event with the selector thread.
-     */
-    void startReading();
-}
--- a/src/java.httpclient/share/classes/java/net/http/AsyncEvent.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.nio.channels.SelectableChannel;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.SocketChannel;
-
-/**
- * Event handling interface from HttpClientImpl's selector.
- *
- * If BLOCKING is set, then the channel will be put in blocking
- * mode prior to handle() being called. If false, then it remains non-blocking.
- *
- * If REPEATING is set then the event is not cancelled after being posted.
- */
-abstract class AsyncEvent {
-
-    public static final int BLOCKING = 0x1; // non blocking if not set
-    public static final int REPEATING = 0x2; // one off event if not set
-
-    protected final int flags;
-
-    AsyncEvent(int flags) {
-        this.flags = flags;
-    }
-
-    /** Returns the channel */
-    public abstract SelectableChannel channel();
-
-    /** Returns the selector interest op flags OR'd */
-    public abstract int interestOps();
-
-    /** Called when event occurs */
-    public abstract void handle();
-
-    /** Called when selector is shutting down. Abort all exchanges. */
-    public abstract void abort();
-
-    public boolean blocking() {
-        return (flags & BLOCKING) != 0;
-    }
-
-    public boolean repeating() {
-        return (flags & REPEATING) != 0;
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/AsyncSSLConnection.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.channels.SocketChannel;
-import java.util.concurrent.CompletableFuture;
-import java.util.function.Consumer;
-
-/**
- * Asynchronous version of SSLConnection.
- */
-class AsyncSSLConnection extends HttpConnection implements AsyncConnection {
-    final AsyncSSLDelegate sslDelegate;
-    final PlainHttpConnection delegate;
-
-    AsyncSSLConnection(InetSocketAddress addr, HttpClientImpl client, String[] ap) {
-        super(addr, client);
-        delegate = new PlainHttpConnection(addr, client);
-        sslDelegate = new AsyncSSLDelegate(delegate, client, ap);
-    }
-
-    @Override
-    public void connect() throws IOException, InterruptedException {
-        delegate.connect();
-    }
-
-    @Override
-    public CompletableFuture<Void> connectAsync() {
-        return delegate.connectAsync();
-    }
-
-    @Override
-    boolean connected() {
-        return delegate.connected();
-    }
-
-    @Override
-    boolean isSecure() {
-        return true;
-    }
-
-    @Override
-    boolean isProxied() {
-        return false;
-    }
-
-    @Override
-    SocketChannel channel() {
-        return delegate.channel();
-    }
-
-    @Override
-    ConnectionPool.CacheKey cacheKey() {
-        return ConnectionPool.cacheKey(address, null);
-    }
-
-    @Override
-    synchronized long write(ByteBuffer[] buffers, int start, int number) throws IOException {
-        ByteBuffer[] bufs = Utils.reduce(buffers, start, number);
-        long n = Utils.remaining(bufs);
-        sslDelegate.write(bufs);
-        return n;
-    }
-
-    @Override
-    long write(ByteBuffer buffer) throws IOException {
-        long n = buffer.remaining();
-        sslDelegate.write(buffer);
-        return n;
-    }
-
-    @Override
-    public void close() {
-        Utils.close(sslDelegate, delegate.channel());
-    }
-
-    @Override
-    public void setAsyncCallbacks(Consumer<ByteBuffer> asyncReceiver, Consumer<Throwable> errorReceiver) {
-        sslDelegate.setAsyncCallbacks(asyncReceiver, errorReceiver);
-        delegate.setAsyncCallbacks(sslDelegate::lowerRead, errorReceiver);
-    }
-
-    // Blocking read functions not used here
-
-    @Override
-    protected ByteBuffer readImpl(int length) throws IOException {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
-    @Override
-    protected int readImpl(ByteBuffer buffer) throws IOException {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
-    @Override
-    CompletableFuture<Void> whenReceivingResponse() {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
-    @Override
-    public void startReading() {
-        delegate.startReading();
-        sslDelegate.startReading();
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,609 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.LinkedList;
-import java.util.concurrent.ExecutorService;
-import java.util.function.Consumer;
-import static javax.net.ssl.SSLEngineResult.Status.*;
-import javax.net.ssl.*;
-import static javax.net.ssl.SSLEngineResult.HandshakeStatus.*;
-
-/**
- * Asynchronous wrapper around SSLEngine. send and receive is fully non
- * blocking. When handshaking is required, a thread is created to perform
- * the handshake and application level sends do not take place during this time.
- *
- * Is implemented using queues and functions operating on the receiving end
- * of each queue.
- *
- * Application writes to:
- *        ||
- *        \/
- *     appOutputQ
- *        ||
- *        \/
- * appOutputQ read by "upperWrite" method which does SSLEngine.wrap
- * and writes to
- *        ||
- *        \/
- *     channelOutputQ
- *        ||
- *        \/
- * channelOutputQ is read by "lowerWrite" method which is invoked from
- * OP_WRITE events on the socket (from selector thread)
- *
- * Reading side is as follows
- * --------------------------
- *
- * "upperRead" method reads off channelInputQ and calls SSLEngine.unwrap and
- * when decrypted data is returned, it is passed to the user's Consumer<ByteBuffer>
- *        /\
- *        ||
- *     channelInputQ
- *        /\
- *        ||
- * "lowerRead" method puts buffers into channelInputQ. It is invoked from
- * OP_READ events from the selector.
- *
- * Whenever handshaking is required, the doHandshaking() method is called
- * which creates a thread to complete the handshake. It takes over the
- * channelInputQ from upperRead, and puts outgoing packets on channelOutputQ.
- * Selector events are delivered to lowerRead and lowerWrite as normal.
- *
- * Errors
- *
- * Any exception thrown by the engine or channel, causes all Queues to be closed
- * the channel to be closed, and the error is reported to the user's
- * Consumer<Throwable>
- */
-class AsyncSSLDelegate implements Closeable, AsyncConnection {
-
-    // outgoing buffers put in this queue first and may remain here
-    // while SSL handshaking happening.
-    final Queue<ByteBuffer> appOutputQ;
-
-    // queue of wrapped ByteBuffers waiting to be sent on socket channel
-    //final Queue<ByteBuffer> channelOutputQ;
-
-    // Bytes read into this queue before being unwrapped. Backup on this
-    // Q should only happen when the engine is stalled due to delegated tasks
-    final Queue<ByteBuffer> channelInputQ;
-
-    // input occurs through the read() method which is expected to be called
-    // when the selector signals some data is waiting to be read. All incoming
-    // handshake data is handled in this method, which means some calls to
-    // read() may return zero bytes of user data. This is not a sign of spinning,
-    // just that the handshake mechanics are being executed.
-
-    final SSLEngine engine;
-    final SSLParameters sslParameters;
-    //final SocketChannel chan;
-    final HttpConnection lowerOutput;
-    final HttpClientImpl client;
-    final ExecutorService executor;
-    final BufferHandler bufPool;
-    Consumer<ByteBuffer> receiver;
-    Consumer<Throwable> errorHandler;
-    // Locks.
-    final Object reader = new Object();
-    final Object writer = new Object();
-    // synchronizing handshake state
-    final Object handshaker = new Object();
-    // flag set when reader or writer is blocked waiting for handshake to finish
-    boolean writerBlocked;
-    boolean readerBlocked;
-
-    // some thread is currently doing the handshake
-    boolean handshaking;
-
-    // alpn[] may be null. upcall is callback which receives incoming decoded bytes off socket
-
-    AsyncSSLDelegate(HttpConnection lowerOutput, HttpClientImpl client, String[] alpn)
-    {
-        SSLContext context = client.sslContext();
-        executor = client.executorService();
-        bufPool = client;
-        appOutputQ = new Queue<>();
-        appOutputQ.registerPutCallback(this::upperWrite);
-        //channelOutputQ = new Queue<>();
-        //channelOutputQ.registerPutCallback(this::lowerWrite);
-        engine = context.createSSLEngine();
-        engine.setUseClientMode(true);
-        SSLParameters sslp = client.sslParameters().orElse(null);
-        if (sslp == null) {
-            sslp = context.getSupportedSSLParameters();
-            //sslp = context.getDefaultSSLParameters();
-            //printParams(sslp);
-        }
-        sslParameters = Utils.copySSLParameters(sslp);
-        if (alpn != null) {
-            sslParameters.setApplicationProtocols(alpn);
-        }
-        logParams(sslParameters);
-        engine.setSSLParameters(sslParameters);
-        this.lowerOutput = lowerOutput;
-        this.client = client;
-        this.channelInputQ = new Queue<>();
-        this.channelInputQ.registerPutCallback(this::upperRead);
-    }
-
-    /**
-     * Put buffers to appOutputQ, and call upperWrite() if q was empty.
-     *
-     * @param src
-     */
-    public void write(ByteBuffer[] src) throws IOException {
-        appOutputQ.putAll(src);
-    }
-
-    public void write(ByteBuffer buf) throws IOException {
-        ByteBuffer[] a = new ByteBuffer[1];
-        a[0] = buf;
-        write(a);
-    }
-
-    @Override
-    public void close() {
-        Utils.close(appOutputQ, channelInputQ, lowerOutput);
-    }
-
-    /**
-     * Attempts to wrap buffers from appOutputQ and place them on the
-     * channelOutputQ for writing. If handshaking is happening, then the
-     * process stalls and last buffers taken off the appOutputQ are put back
-     * into it until handshaking completes.
-     *
-     * This same method is called to try and resume output after a blocking
-     * handshaking operation has completed.
-     */
-    private void upperWrite() {
-        try {
-            EngineResult r = null;
-            ByteBuffer[] buffers = appOutputQ.pollAll(Utils.EMPTY_BB_ARRAY);
-            int bytes = Utils.remaining(buffers);
-            while (bytes > 0) {
-                synchronized (writer) {
-                    r = wrapBuffers(buffers);
-                    int bytesProduced = r.bytesProduced();
-                    int bytesConsumed = r.bytesConsumed();
-                    bytes -= bytesConsumed;
-                    if (bytesProduced > 0) {
-                        // pass destination buffer to channelOutputQ.
-                        lowerOutput.write(r.destBuffer);
-                    }
-                    synchronized (handshaker) {
-                        if (r.handshaking()) {
-                            // handshaking is happening or is needed
-                            // so we put the buffers back on Q to process again
-                            // later. It's possible that some may have already
-                            // been processed, which is ok.
-                            appOutputQ.pushbackAll(buffers);
-                            writerBlocked = true;
-                            if (!handshaking()) {
-                                // execute the handshake in another thread.
-                                // This method will be called again to resume sending
-                                // later
-                                doHandshake(r);
-                            }
-                            return;
-                        }
-                    }
-                }
-            }
-            returnBuffers(buffers);
-        } catch (Throwable t) {
-            close();
-            errorHandler.accept(t);
-        }
-    }
-
-    private void doHandshake(EngineResult r) {
-        handshaking = true;
-        channelInputQ.registerPutCallback(null);
-        executor.execute(() -> {
-            try {
-                doHandshakeImpl(r);
-                channelInputQ.registerPutCallback(this::upperRead);
-            } catch (Throwable t) {
-                close();
-                errorHandler.accept(t);
-            }
-        });
-    }
-
-    private void returnBuffers(ByteBuffer[] bufs) {
-        for (ByteBuffer buf : bufs)
-            client.returnBuffer(buf);
-    }
-
-    /**
-     * Return true if some thread is currently doing the handshake
-     *
-     * @return
-     */
-    boolean handshaking() {
-        synchronized(handshaker) {
-            return handshaking;
-        }
-    }
-
-    /**
-     * Executes entire handshake in calling thread.
-     * Returns after handshake is completed or error occurs
-     * @param r
-     * @throws IOException
-     */
-    private void doHandshakeImpl(EngineResult r) throws IOException {
-        while (true) {
-            SSLEngineResult.HandshakeStatus status = r.handshakeStatus();
-            if (status == NEED_TASK) {
-                LinkedList<Runnable> tasks = obtainTasks();
-                for (Runnable task : tasks)
-                    task.run();
-                r = handshakeWrapAndSend();
-            } else if (status == NEED_WRAP) {
-                r = handshakeWrapAndSend();
-            } else if (status == NEED_UNWRAP) {
-                r = handshakeReceiveAndUnWrap();
-            }
-            if (!r.handshaking())
-                break;
-        }
-        boolean dowrite = false;
-        boolean doread = false;
-        // Handshake is finished. Now resume reading and/or writing
-        synchronized(handshaker) {
-            handshaking = false;
-            if (writerBlocked) {
-                writerBlocked = false;
-                dowrite = true;
-            }
-            if (readerBlocked) {
-                readerBlocked = false;
-                doread = true;
-            }
-        }
-        if (dowrite)
-            upperWrite();
-        if (doread)
-            upperRead();
-    }
-
-    // acknowledge a received CLOSE request from peer
-    void doClosure() throws IOException {
-        //while (!wrapAndSend(emptyArray))
-            //;
-    }
-
-    LinkedList<Runnable> obtainTasks() {
-        LinkedList<Runnable> l = new LinkedList<>();
-        Runnable r;
-        while ((r = engine.getDelegatedTask()) != null)
-            l.add(r);
-        return l;
-    }
-
-    @Override
-    public synchronized void setAsyncCallbacks(Consumer<ByteBuffer> asyncReceiver, Consumer<Throwable> errorReceiver) {
-        this.receiver = asyncReceiver;
-        this.errorHandler = errorReceiver;
-    }
-
-    @Override
-    public void startReading() {
-        // maybe this class does not need to implement AsyncConnection
-    }
-
-    static class EngineResult {
-        ByteBuffer destBuffer;
-        ByteBuffer srcBuffer;
-        SSLEngineResult result;
-        Throwable t;
-
-        boolean handshaking() {
-            SSLEngineResult.HandshakeStatus s = result.getHandshakeStatus();
-            return s != FINISHED && s != NOT_HANDSHAKING;
-        }
-
-        int bytesConsumed() {
-            return result.bytesConsumed();
-        }
-
-        int bytesProduced() {
-            return result.bytesProduced();
-        }
-
-        Throwable exception() {
-            return t;
-        }
-
-        SSLEngineResult.HandshakeStatus handshakeStatus() {
-            return result.getHandshakeStatus();
-        }
-
-        SSLEngineResult.Status status() {
-            return result.getStatus();
-        }
-    }
-
-    EngineResult handshakeWrapAndSend() throws IOException {
-        EngineResult r = wrapBuffer(Utils.EMPTY_BYTEBUFFER);
-        if (r.bytesProduced() > 0) {
-            lowerOutput.write(r.destBuffer);
-        }
-        return r;
-    }
-
-    // called during handshaking. It blocks until a complete packet
-    // is available, unwraps it and returns.
-    EngineResult handshakeReceiveAndUnWrap() throws IOException {
-        ByteBuffer buf = channelInputQ.take();
-        while (true) {
-            // block waiting for input
-            EngineResult r = unwrapBuffer(buf);
-            SSLEngineResult.Status status = r.status();
-            if (status == BUFFER_UNDERFLOW) {
-                // wait for another buffer to arrive
-                ByteBuffer buf1 = channelInputQ.take();
-                buf = combine (buf, buf1);
-                continue;
-            }
-            // OK
-            // theoretically possible we could receive some user data
-            if (r.bytesProduced() > 0) {
-                receiver.accept(r.destBuffer);
-            }
-            if (!buf.hasRemaining())
-                return r;
-        }
-    }
-
-    EngineResult wrapBuffer(ByteBuffer src) throws SSLException {
-        ByteBuffer[] bufs = new ByteBuffer[1];
-        bufs[0] = src;
-        return wrapBuffers(bufs);
-    }
-
-    EngineResult wrapBuffers(ByteBuffer[] src) throws SSLException {
-        EngineResult r = new EngineResult();
-        ByteBuffer dst = bufPool.getBuffer();
-        while (true) {
-            r.result = engine.wrap(src, dst);
-            switch (r.result.getStatus()) {
-                case BUFFER_OVERFLOW:
-                    dst = getPacketBuffer();
-                    break;
-                case CLOSED:
-                case OK:
-                    dst.flip();
-                    r.destBuffer = dst;
-                    return r;
-                case BUFFER_UNDERFLOW:
-                    // underflow handled externally
-                    bufPool.returnBuffer(dst);
-                    return r;
-                default:
-                    assert false;
-            }
-        }
-    }
-
-    EngineResult unwrapBuffer(ByteBuffer srcbuf) throws IOException {
-        EngineResult r = new EngineResult();
-        r.srcBuffer = srcbuf;
-
-        ByteBuffer dst = bufPool.getBuffer();
-        while (true) {
-            r.result = engine.unwrap(srcbuf, dst);
-            switch (r.result.getStatus()) {
-                case BUFFER_OVERFLOW:
-                    // dest buffer not big enough. Reallocate
-                    int oldcap = dst.capacity();
-                    dst = getApplicationBuffer();
-                    assert dst.capacity() > oldcap;
-                    break;
-                case CLOSED:
-                    doClosure();
-                    throw new IOException("Engine closed");
-                case BUFFER_UNDERFLOW:
-                    bufPool.returnBuffer(dst);
-                    return r;
-                case OK:
-                    dst.flip();
-                    r.destBuffer = dst;
-                    return r;
-            }
-        }
-    }
-
-    /**
-     * Asynchronous read input. Call this when selector fires.
-     * Unwrap done in upperRead because it also happens in
-     * doHandshake() when handshake taking place
-     */
-    public void lowerRead(ByteBuffer buffer) {
-        try {
-            channelInputQ.put(buffer);
-        } catch (Throwable t) {
-            close();
-            errorHandler.accept(t);
-        }
-    }
-
-    public void upperRead() {
-        EngineResult r;
-        ByteBuffer srcbuf;
-        synchronized (reader) {
-            try {
-                srcbuf = channelInputQ.poll();
-                if (srcbuf == null) {
-                    return;
-                }
-                while (true) {
-                    r = unwrapBuffer(srcbuf);
-                    switch (r.result.getStatus()) {
-                        case BUFFER_UNDERFLOW:
-                            // Buffer too small. Need to combine with next buf
-                            ByteBuffer nextBuf = channelInputQ.poll();
-                            if (nextBuf == null) {
-                                // no data available. push buffer back until more data available
-                                channelInputQ.pushback(srcbuf);
-                                return;
-                            } else {
-                                srcbuf = combine(srcbuf, nextBuf);
-                            }
-                            break;
-                        case OK:
-                            // check for any handshaking work
-                            synchronized (handshaker) {
-                                if (r.handshaking()) {
-                                    // handshaking is happening or is needed
-                                    // so we put the buffer back on Q to process again
-                                    // later.
-                                    channelInputQ.pushback(srcbuf);
-                                    readerBlocked = true;
-                                    if (!handshaking()) {
-                                        // execute the handshake in another thread.
-                                        // This method will be called again to resume sending
-                                        // later
-                                        doHandshake(r);
-                                    }
-                                    return;
-                                }
-                            }
-                            ByteBuffer dst = r.destBuffer;
-                            if (dst.hasRemaining()) {
-                                receiver.accept(dst);
-                            }
-                    }
-                    if (srcbuf.hasRemaining()) {
-                        continue;
-                    }
-                    srcbuf = channelInputQ.poll();
-                    if (srcbuf == null) {
-                        return;
-                    }
-                }
-            } catch (Throwable t) {
-                close();
-                errorHandler.accept(t);
-            }
-        }
-    }
-
-    /**
-     * Get a new buffer that is the right size for application buffers.
-     *
-     * @return
-     */
-    ByteBuffer getApplicationBuffer() {
-        SSLSession session = engine.getSession();
-        int appBufsize = session.getApplicationBufferSize();
-        bufPool.setMinBufferSize(appBufsize);
-        return bufPool.getBuffer(appBufsize);
-    }
-
-    ByteBuffer getPacketBuffer() {
-        SSLSession session = engine.getSession();
-        int packetBufSize = session.getPacketBufferSize();
-        bufPool.setMinBufferSize(packetBufSize);
-        return bufPool.getBuffer(packetBufSize);
-    }
-
-    ByteBuffer combine(ByteBuffer buf1, ByteBuffer buf2) {
-        int avail1 = buf1.capacity() - buf1.remaining();
-        if (buf2.remaining() < avail1) {
-            buf1.compact();
-            buf1.put(buf2);
-            buf1.flip();
-            return buf1;
-        }
-        int newsize = buf1.remaining() + buf2.remaining();
-        ByteBuffer newbuf = bufPool.getBuffer(newsize);
-        newbuf.put(buf1);
-        newbuf.put(buf2);
-        newbuf.flip();
-        return newbuf;
-    }
-
-    SSLParameters getSSLParameters() {
-        return sslParameters;
-    }
-
-    static void logParams(SSLParameters p) {
-        if (!Log.ssl()) {
-            return;
-        }
-
-        Log.logSSL("SSLParameters:");
-        if (p == null) {
-            Log.logSSL("Null params");
-            return;
-        }
-
-        if (p.getCipherSuites() != null) {
-            for (String cipher : p.getCipherSuites()) {
-                Log.logSSL("cipher: {0}\n", cipher);
-            }
-        }
-
-        // SSLParameters.getApplicationProtocols() can't return null
-        for (String approto : p.getApplicationProtocols()) {
-            Log.logSSL("application protocol: {0}\n", approto);
-        }
-
-        if (p.getProtocols() != null) {
-            for (String protocol : p.getProtocols()) {
-                Log.logSSL("protocol: {0}\n", protocol);
-            }
-        }
-
-        if (p.getServerNames() != null) {
-            for (SNIServerName sname : p.getServerNames()) {
-                Log.logSSL("server name: {0}\n", sname.toString());
-            }
-        }
-    }
-
-    String getSessionInfo() {
-        StringBuilder sb = new StringBuilder();
-        String application = engine.getApplicationProtocol();
-        SSLSession sess = engine.getSession();
-        String cipher = sess.getCipherSuite();
-        String protocol = sess.getProtocol();
-        sb.append("Handshake complete alpn: ")
-                .append(application)
-                .append(", Cipher: ")
-                .append(cipher)
-                .append(", Protocol: ")
-                .append(protocol);
-        return sb.toString();
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/AuthenticationFilter.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,308 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import static java.net.Authenticator.RequestorType.PROXY;
-import static java.net.Authenticator.RequestorType.SERVER;
-import java.net.PasswordAuthentication;
-import java.net.URI;
-import java.net.InetSocketAddress;
-import java.net.URISyntaxException;
-import java.util.Base64;
-import java.util.HashMap;
-import java.util.LinkedList;
-import static java.nio.charset.StandardCharsets.ISO_8859_1;
-
-/**
- * Implementation of Http Basic authentication.
- */
-class AuthenticationFilter implements HeaderFilter {
-
-    static private final Base64.Encoder encoder = Base64.getEncoder();
-
-    static final int DEFAULT_RETRY_LIMIT = 3;
-
-    static final int retry_limit = Utils.getIntegerNetProperty(
-            "java.net.httpclient.auth.retrylimit", DEFAULT_RETRY_LIMIT);
-
-    static final int UNAUTHORIZED = 401;
-    static final int PROXY_UNAUTHORIZED = 407;
-
-    private PasswordAuthentication getCredentials(String header,
-                                                  boolean proxy,
-                                                  HttpRequestImpl req)
-        throws IOException
-    {
-        HttpClientImpl client = req.client();
-        java.net.Authenticator auth =
-                client.authenticator()
-                      .orElseThrow(() -> new IOException("No authenticator set"));
-        URI uri = req.uri();
-        HeaderParser parser = new HeaderParser(header);
-        String authscheme = parser.findKey(0);
-
-        String realm = parser.findValue("realm");
-        java.net.Authenticator.RequestorType rtype = proxy ? PROXY : SERVER;
-
-        // needs to be instance method in Authenticator
-        return auth.requestPasswordAuthenticationInstance(uri.getHost(),
-                                                          null,
-                                                          uri.getPort(),
-                                                          uri.getScheme(),
-                                                          realm,
-                                                          authscheme,
-                                                          uri.toURL(),
-                                                          rtype
-        );
-    }
-
-    private URI getProxyURI(HttpRequestImpl r) {
-        InetSocketAddress proxy = r.proxy();
-        if (proxy == null) {
-            return null;
-        }
-
-        // our own private scheme for proxy URLs
-        // eg. proxy.http://host:port/
-        String scheme = "proxy." + r.uri().getScheme();
-        try {
-            return new URI(scheme,
-                           null,
-                           proxy.getHostString(),
-                           proxy.getPort(),
-                           null,
-                           null,
-                           null);
-        } catch (URISyntaxException e) {
-            throw new InternalError(e);
-        }
-    }
-
-    @Override
-    public void request(HttpRequestImpl r) throws IOException {
-        // use preemptive authentication if an entry exists.
-        Cache cache = getCache(r);
-
-        // Proxy
-        if (r.exchange.proxyauth == null) {
-            URI proxyURI = getProxyURI(r);
-            if (proxyURI != null) {
-                CacheEntry ca = cache.get(proxyURI, true);
-                if (ca != null) {
-                    r.exchange.proxyauth = new AuthInfo(true, ca.scheme, null, ca);
-                    addBasicCredentials(r, true, ca.value);
-                }
-            }
-        }
-
-        // Server
-        if (r.exchange.serverauth == null) {
-            CacheEntry ca = cache.get(r.uri(), false);
-            if (ca != null) {
-                r.exchange.serverauth = new AuthInfo(true, ca.scheme, null, ca);
-                addBasicCredentials(r, false, ca.value);
-            }
-        }
-    }
-
-    // TODO: refactor into per auth scheme class
-    static private void addBasicCredentials(HttpRequestImpl r,
-                                            boolean proxy,
-                                            PasswordAuthentication pw) {
-        String hdrname = proxy ? "Proxy-Authorization" : "Authorization";
-        StringBuilder sb = new StringBuilder(128);
-        sb.append(pw.getUserName()).append(':').append(pw.getPassword());
-        String s = encoder.encodeToString(sb.toString().getBytes(ISO_8859_1));
-        String value = "Basic " + s;
-        r.setSystemHeader(hdrname, value);
-    }
-
-    // Information attached to a HttpRequestImpl relating to authentication
-    static class AuthInfo {
-        final boolean fromcache;
-        final String scheme;
-        int retries;
-        PasswordAuthentication credentials; // used in request
-        CacheEntry cacheEntry; // if used
-
-        AuthInfo(boolean fromcache,
-                 String scheme,
-                 PasswordAuthentication credentials) {
-            this.fromcache = fromcache;
-            this.scheme = scheme;
-            this.credentials = credentials;
-            this.retries = 1;
-        }
-
-        AuthInfo(boolean fromcache,
-                 String scheme,
-                 PasswordAuthentication credentials,
-                 CacheEntry ca) {
-            this(fromcache, scheme, credentials);
-            assert credentials == null || (ca != null && ca.value == null);
-            cacheEntry = ca;
-        }
-    }
-
-    @Override
-    public HttpRequestImpl response(HttpResponseImpl r) throws IOException {
-        Cache cache = getCache(r.request);
-        int status = r.statusCode();
-        HttpHeaders hdrs = r.headers();
-        HttpRequestImpl req = r.request();
-
-        if (status != UNAUTHORIZED && status != PROXY_UNAUTHORIZED) {
-            // check if any authentication succeeded for first time
-            if (req.exchange.serverauth != null && !req.exchange.serverauth.fromcache) {
-                AuthInfo au = req.exchange.serverauth;
-                cache.store(au.scheme, req.uri(), false, au.credentials);
-            }
-            if (req.exchange.proxyauth != null && !req.exchange.proxyauth.fromcache) {
-                AuthInfo au = req.exchange.proxyauth;
-                cache.store(au.scheme, req.uri(), false, au.credentials);
-            }
-            return null;
-        }
-
-        boolean proxy = status == PROXY_UNAUTHORIZED;
-        String authname = proxy ? "Proxy-Authenticate" : "WWW-Authenticate";
-        String authval = hdrs.firstValue(authname).orElseThrow(() -> {
-            return new IOException("Invalid auth header");
-        });
-        HeaderParser parser = new HeaderParser(authval);
-        String scheme = parser.findKey(0);
-
-        // TODO: Need to generalise from Basic only. Delegate to a provider class etc.
-
-        if (!scheme.equalsIgnoreCase("Basic")) {
-            return null;   // error gets returned to app
-        }
-
-        String realm = parser.findValue("realm");
-        AuthInfo au = proxy ? req.exchange.proxyauth : req.exchange.serverauth;
-        if (au == null) {
-            PasswordAuthentication pw = getCredentials(authval, proxy, req);
-            if (pw == null) {
-                throw new IOException("No credentials provided");
-            }
-            // No authentication in request. Get credentials from user
-            au = new AuthInfo(false, "Basic", pw);
-            if (proxy)
-                req.exchange.proxyauth = au;
-            else
-                req.exchange.serverauth = au;
-            addBasicCredentials(req, proxy, pw);
-            return req;
-        } else if (au.retries > retry_limit) {
-            throw new IOException("too many authentication attempts");
-        } else {
-            // we sent credentials, but they were rejected
-            if (au.fromcache) {
-                cache.remove(au.cacheEntry);
-            }
-            // try again
-            au.credentials = getCredentials(authval, proxy, req);
-            addBasicCredentials(req, proxy, au.credentials);
-            au.retries++;
-            return req;
-        }
-    }
-
-    static final HashMap<HttpClientImpl,Cache> caches = new HashMap<>();
-
-    static synchronized Cache getCache(HttpRequestImpl req) {
-        HttpClientImpl client = req.client();
-        Cache c = caches.get(client);
-        if (c == null) {
-            c = new Cache();
-            caches.put(client, c);
-        }
-        return c;
-    }
-
-    static class Cache {
-        final LinkedList<CacheEntry> entries = new LinkedList<>();
-
-        synchronized CacheEntry get(URI uri, boolean proxy) {
-            for (CacheEntry entry : entries) {
-                if (entry.equalsKey(uri, proxy)) {
-                    return entry;
-                }
-            }
-            return null;
-        }
-
-        synchronized void remove(String authscheme, URI domain, boolean proxy) {
-            for (CacheEntry entry : entries) {
-                if (entry.equalsKey(domain, proxy)) {
-                    entries.remove(entry);
-                }
-            }
-        }
-
-        synchronized void remove(CacheEntry entry) {
-            entries.remove(entry);
-        }
-
-        synchronized void store(String authscheme,
-                                URI domain,
-                                boolean proxy,
-                                PasswordAuthentication value) {
-            remove(authscheme, domain, proxy);
-            entries.add(new CacheEntry(authscheme, domain, proxy, value));
-        }
-    }
-
-    static class CacheEntry {
-        final String root;
-        final String scheme;
-        final boolean proxy;
-        final PasswordAuthentication value;
-
-        CacheEntry(String authscheme,
-                   URI uri,
-                   boolean proxy,
-                   PasswordAuthentication value) {
-            this.scheme = authscheme;
-            this.root = uri.resolve(".").toString(); // remove extraneous components
-            this.proxy = proxy;
-            this.value = value;
-        }
-
-        public PasswordAuthentication value() {
-            return value;
-        }
-
-        public boolean equalsKey(URI uri, boolean proxy) {
-            if (this.proxy != proxy) {
-                return false;
-            }
-            String other = uri.toString();
-            return other.startsWith(root);
-        }
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/BufferHandler.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.nio.ByteBuffer;
-
-/**
- * Implemented by buffer pools. A buffer pool has a current buffer size
- * (number of bytes in each buffer) which may increase over time.
- */
-interface BufferHandler {
-
-    default ByteBuffer getBuffer() {
-        return getBuffer(-1);
-    }
-
-    void setMinBufferSize(int size);
-
-    /**
-     * size == -1 means return any sized buffer. Any other value means
-     * @param size
-     * @return
-     */
-    ByteBuffer getBuffer(int size);
-
-    void returnBuffer(ByteBuffer buffer);
-}
--- a/src/java.httpclient/share/classes/java/net/http/ByteBufferConsumer.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.function.Supplier;
-
-/**
- * Takes a List<ByteBuffer> which is assumed to contain at least one HTTP/2
- * frame and allows it to be processed supplying bytes, ints, shorts, byte[] etc.
- * from the list. As each ByteBuffer is consumed it is removed from the List<>.
- *
- * NOTE. shorts and bytes returned are UNSIGNED ints
- *
- * When finished processing the frame, the List may be empty or may contain
- * partially read or unread ByteBuffers. A new ByteBufferConsumer can be
- * created with the List<>
- */
-class ByteBufferConsumer {
-
-    ByteBuffer currentBuffer;
-
-    final List<ByteBuffer> buffers;
-    final ListIterator<ByteBuffer> iterator;
-    final Supplier<ByteBuffer> newBufferSupplier;
-
-    ByteBufferConsumer(List<ByteBuffer> buffers,
-                       Supplier<ByteBuffer> newBufferSupplier) {
-        this.buffers = buffers;
-        this.newBufferSupplier = newBufferSupplier;
-        this.iterator = buffers.listIterator();
-        if (!iterator.hasNext()) {
-            throw new IllegalArgumentException("Empty buffer list");
-        }
-        currentBuffer = iterator.next();
-    }
-
-    private void dump() {
-        int l = 0;
-        System.err.printf("ByteBufferConsumer:\n");
-        for (ByteBuffer buf : buffers) {
-            System.err.printf("\t%s\n", buf.toString());
-            l+= buf.remaining();
-        }
-        System.err.printf("BBC contains %d bytes\n", l);
-    }
-
-    private synchronized ByteBuffer getBuffer(boolean exception) throws IOException {
-        while (currentBuffer == null || !currentBuffer.hasRemaining()) {
-            if (currentBuffer != null) {
-                iterator.remove();
-            }
-            if (!iterator.hasNext()) {
-                currentBuffer = null;
-                if (exception) {
-                    throw new IOException ("Connection closed unexpectedly");
-                }
-                return null;
-            }
-            currentBuffer = iterator.next();
-        }
-        return currentBuffer;
-    }
-
-    // call this to check if the data has all been consumed
-
-    public boolean consumed() {
-        try {
-            return getBuffer(false) == null;
-        } catch (IOException e) {
-            /* CAN'T HAPPEN */
-            throw new InternalError();
-        }
-    }
-
-    public int getByte() throws IOException {
-        // TODO: what to do if connection is closed. Throw NPE?
-        ByteBuffer buf = getBuffer(true);
-        return buf.get() & 0xff;
-    }
-
-    public byte[] getBytes(int n) throws IOException {
-        return getBytes(n, null);
-    }
-
-    public byte[] getBytes(int n, byte[] buf) throws IOException {
-        if (buf == null) {
-            buf = new byte[n];
-        } else if (buf.length < n) {
-            throw new IllegalArgumentException("getBytes: buffer too small");
-        }
-        int offset = 0;
-        while (n > 0) {
-            ByteBuffer b = getBuffer(true);
-            int length = Math.min(n, b.remaining());
-            b.get(buf, offset, length);
-            offset += length;
-            n -= length;
-        }
-        return buf;
-    }
-
-    public int getShort() throws IOException {
-        ByteBuffer buf = getBuffer(true);
-        int rem = buf.remaining();
-        if (rem >= 2) {
-            return buf.getShort() & 0xffff;
-        }
-        // Slow path. Not common
-        int val = 0;
-        val = (val << 8) + getByte();
-        val = (val << 8) + getByte();
-        return val;
-    }
-
-    public int getInt() throws IOException {
-        ByteBuffer buf = getBuffer(true);
-        int rem = buf.remaining();
-        if (rem >= 4) {
-            return buf.getInt();
-        }
-        // Slow path. Not common
-        int val = 0;
-        for (int nbytes = 0; nbytes < 4; nbytes++) {
-            val = (val << 8) + getByte();
-        }
-        return val;
-    }
-
-    private static final ByteBuffer[] EMPTY = new ByteBuffer[0];
-
-    /**
-     * Extracts whatever number of ByteBuffers from list to get required number
-     * of bytes. Any remaining buffers are 'tidied up' so reading can continue.
-     */
-    public ByteBuffer[] getBuffers(int bytecount) throws IOException {
-        LinkedList<ByteBuffer> l = new LinkedList<>();
-        while (bytecount > 0) {
-            ByteBuffer buffer = getBuffer(true);
-            int remaining = buffer.remaining();
-            if (remaining > bytecount) {
-                int difference = remaining - bytecount;
-                // split
-                ByteBuffer newb = newBufferSupplier.get();
-                newb.clear();
-                int limit = buffer.limit();
-                buffer.limit(limit - difference);
-                newb.put(buffer);
-                newb.flip();
-                buffer.limit(limit);
-                l.add(newb);
-                bytecount = 0;
-            } else {
-                l.add(buffer);
-                currentBuffer = null;
-                iterator.remove();
-                bytecount -= remaining;
-            }
-        }
-        return l.toArray(EMPTY);
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/ByteBufferGenerator.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-
-/**
- * Manages a ByteBuffer[] for writing frames into for output. The last
- * ByteBuffer in the list is always unflipped (able to receive more bytes for
- * sending) until getBufferArray() is called, which calls finish().
- *
- * This allows multiple frames to be written to the same BBG.
- *
- * Buffers added with addByteBuffer() must be already flipped.
- */
-class ByteBufferGenerator {
-
-    ByteBuffer currentBuffer;
-    // source is assumed to always return the same sized buffer
-    final BufferHandler pool;
-    final ArrayList<ByteBuffer> buflist;
-    final int bufsize;
-    boolean finished;
-
-    ByteBufferGenerator(BufferHandler pool) {
-        this.buflist = new ArrayList<>();
-        this.pool = pool;
-        this.currentBuffer = pool.getBuffer();
-        this.bufsize = currentBuffer.capacity();
-    }
-
-    private static final ByteBuffer[] EMPTY = new ByteBuffer[0];
-
-    public ByteBuffer[] getBufferArray() {
-        finish();
-        return buflist.toArray(EMPTY);
-    }
-
-    public ArrayList<ByteBuffer> getBufferList() {
-        finish();
-        return buflist;
-    }
-
-    private synchronized void finish() {
-        if (finished) {
-            return;
-        }
-        finished = true;
-        currentBuffer.flip();
-        if (currentBuffer.hasRemaining()) {
-            buflist.add(currentBuffer);
-        } else {
-            pool.returnBuffer(currentBuffer);
-        }
-    }
-
-    // only used for SettingsFrame: offset is number of bytes to
-    // ignore at start (we only want the payload of the settings frame)
-    public byte[] asByteArray(int offset) {
-        ByteBuffer[] bufs = getBufferArray();
-        int size = 0;
-        for (ByteBuffer buf : bufs) {
-            size += buf.remaining();
-        }
-        byte[] bytes = new byte[size-offset];
-        int pos = 0;
-        for (ByteBuffer buf : bufs) {
-            int rem = buf.remaining();
-            int ignore = Math.min(rem, offset);
-            buf.position(buf.position()+ignore);
-            rem -= ignore;
-            offset -= ignore;
-            buf.get(bytes, pos, rem);
-            pos += rem;
-        }
-        return bytes;
-    }
-
-    ByteBuffer getBuffer(long n) {
-        if (currentBuffer.remaining() < n) {
-            getNewBuffer();
-            if (n > currentBuffer.capacity()) {
-                throw new IllegalArgumentException("requested buffer too large");
-            }
-        }
-        return currentBuffer;
-    }
-
-    void getNewBuffer() {
-        currentBuffer.flip();
-        if (currentBuffer.hasRemaining()) {
-            buflist.add(currentBuffer);
-        } else {
-            pool.returnBuffer(currentBuffer);
-        }
-        currentBuffer = pool.getBuffer();
-    }
-
-    void addByteBuffer(ByteBuffer buf) {
-        getNewBuffer();
-        buflist.add(buf);
-    }
-
-    void addPadding(int length) {
-        while (length > 0) {
-            int n = Math.min(length, bufsize);
-            ByteBuffer b = getBuffer(n);
-            // TODO: currently zeroed?
-            b.position(b.position() + n);
-            length -= n;
-        }
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/CharsetToolkit.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CoderResult;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-// The purpose of this class is to separate charset-related tasks from the main
-// WebSocket logic, simplifying where possible.
-//
-//     * Coders hide the differences between coding and flushing stages on the
-//       API level
-//     * Verifier abstracts the way the verification is performed
-//       (spoiler: it's a decoding into a throw-away buffer)
-//
-// Coding methods throw exceptions instead of returning coding result denoting
-// errors, since any kind of handling and recovery is not expected.
-final class CharsetToolkit {
-
-    private CharsetToolkit() { }
-
-    static final class Verifier {
-
-        private final CharsetDecoder decoder = UTF_8.newDecoder();
-        // A buffer used to check validity of UTF-8 byte stream by decoding it.
-        // The contents of this buffer are never used.
-        // The size is arbitrary, though it should probably be chosen from the
-        // performance perspective since it affects the total number of calls to
-        // decoder.decode() and amount of work in each of these calls
-        private final CharBuffer blackHole = CharBuffer.allocate(1024);
-
-        void verify(ByteBuffer in, boolean endOfInput)
-                throws CharacterCodingException {
-            while (true) {
-                // Since decoder.flush() cannot produce an error, it's not
-                // helpful for verification. Therefore this step is skipped.
-                CoderResult r = decoder.decode(in, blackHole, endOfInput);
-                if (r.isOverflow()) {
-                    blackHole.clear();
-                } else if (r.isUnderflow()) {
-                    break;
-                } else if (r.isError()) {
-                    r.throwException();
-                } else {
-                    // Should not happen
-                    throw new InternalError();
-                }
-            }
-        }
-
-        Verifier reset() {
-            decoder.reset();
-            return this;
-        }
-    }
-
-    static final class Encoder {
-
-        private final CharsetEncoder encoder = UTF_8.newEncoder();
-        private boolean coding = true;
-
-        CoderResult encode(CharBuffer in, ByteBuffer out, boolean endOfInput)
-                throws CharacterCodingException {
-
-            if (coding) {
-                CoderResult r = encoder.encode(in, out, endOfInput);
-                if (r.isOverflow()) {
-                    return r;
-                } else if (r.isUnderflow()) {
-                    if (endOfInput) {
-                        coding = false;
-                    } else {
-                        return r;
-                    }
-                } else if (r.isError()) {
-                    r.throwException();
-                } else {
-                    // Should not happen
-                    throw new InternalError();
-                }
-            }
-            assert !coding;
-            return encoder.flush(out);
-        }
-
-        Encoder reset() {
-            coding = true;
-            encoder.reset();
-            return this;
-        }
-    }
-
-    static CharBuffer decode(ByteBuffer in) throws CharacterCodingException {
-        return UTF_8.newDecoder().decode(in);
-    }
-
-    static final class Decoder {
-
-        private final CharsetDecoder decoder = UTF_8.newDecoder();
-        private boolean coding = true; // Either coding or flushing
-
-        CoderResult decode(ByteBuffer in, CharBuffer out, boolean endOfInput)
-                throws CharacterCodingException {
-
-            if (coding) {
-                CoderResult r = decoder.decode(in, out, endOfInput);
-                if (r.isOverflow()) {
-                    return r;
-                } else if (r.isUnderflow()) {
-                    if (endOfInput) {
-                        coding = false;
-                    } else {
-                        return r;
-                    }
-                } else if (r.isError()) {
-                    r.throwException();
-                } else {
-                    // Should not happen
-                    throw new InternalError();
-                }
-            }
-            assert !coding;
-            return decoder.flush(out);
-        }
-
-        Decoder reset() {
-            coding = true;
-            decoder.reset();
-            return this;
-        }
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/ConnectionPool.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,274 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.net.InetSocketAddress;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.ListIterator;
-import java.util.Objects;
-
-/**
- * Http 1.1 connection pool.
- */
-class ConnectionPool {
-
-    static final long KEEP_ALIVE = Utils.getIntegerNetProperty(
-            "java.net.httpclient.keepalive.timeout", 1200); // seconds
-
-    // Pools of idle connections
-
-    final HashMap<CacheKey,LinkedList<HttpConnection>> plainPool;
-    final HashMap<CacheKey,LinkedList<HttpConnection>> sslPool;
-    CacheCleaner cleaner;
-
-    /**
-     * Entries in connection pool are keyed by destination address and/or
-     * proxy address:
-     * case 1: plain TCP not via proxy (destination only)
-     * case 2: plain TCP via proxy (proxy only)
-     * case 3: SSL not via proxy (destination only)
-     * case 4: SSL over tunnel (destination and proxy)
-     */
-    static class CacheKey {
-        final InetSocketAddress proxy;
-        final InetSocketAddress destination;
-
-        CacheKey(InetSocketAddress destination, InetSocketAddress proxy) {
-            this.proxy = proxy;
-            this.destination = destination;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (obj == null) {
-                return false;
-            }
-            if (getClass() != obj.getClass()) {
-                return false;
-            }
-            final CacheKey other = (CacheKey) obj;
-            if (!Objects.equals(this.proxy, other.proxy)) {
-                return false;
-            }
-            if (!Objects.equals(this.destination, other.destination)) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public int hashCode() {
-            return Objects.hash(proxy, destination);
-        }
-    }
-
-    static class ExpiryEntry {
-        final HttpConnection connection;
-        final long expiry; // absolute time in seconds of expiry time
-        ExpiryEntry(HttpConnection connection, long expiry) {
-            this.connection = connection;
-            this.expiry = expiry;
-        }
-    }
-
-    final LinkedList<ExpiryEntry> expiryList;
-
-    /**
-     * There should be one of these per HttpClient.
-     */
-    ConnectionPool() {
-        plainPool = new HashMap<>();
-        sslPool = new HashMap<>();
-        expiryList = new LinkedList<>();
-        cleaner = new CacheCleaner();
-    }
-
-    void start() {
-        cleaner.start();
-    }
-
-    static CacheKey cacheKey(InetSocketAddress destination,
-                             InetSocketAddress proxy) {
-        return new CacheKey(destination, proxy);
-    }
-
-    synchronized HttpConnection getConnection(boolean secure,
-                                              InetSocketAddress addr,
-                                              InetSocketAddress proxy) {
-        CacheKey key = new CacheKey(addr, proxy);
-        HttpConnection c = secure ? findConnection(key, sslPool)
-                                  : findConnection(key, plainPool);
-        //System.out.println ("getConnection returning: " + c);
-        return c;
-    }
-
-    /**
-     * Returns the connection to the pool.
-     *
-     * @param conn
-     */
-    synchronized void returnToPool(HttpConnection conn) {
-        if (conn instanceof PlainHttpConnection) {
-            putConnection(conn, plainPool);
-        } else {
-            putConnection(conn, sslPool);
-        }
-        addToExpiryList(conn);
-        //System.out.println("Return to pool: " + conn);
-    }
-
-    private HttpConnection
-    findConnection(CacheKey key,
-                   HashMap<CacheKey,LinkedList<HttpConnection>> pool) {
-        LinkedList<HttpConnection> l = pool.get(key);
-        if (l == null || l.size() == 0) {
-            return null;
-        } else {
-            HttpConnection c = l.removeFirst();
-            removeFromExpiryList(c);
-            return c;
-        }
-    }
-
-    /* called from cache cleaner only  */
-    private void
-    removeFromPool(HttpConnection c,
-                   HashMap<CacheKey,LinkedList<HttpConnection>> pool) {
-        //System.out.println("cacheCleaner removing: " + c);
-        LinkedList<HttpConnection> l = pool.get(c.cacheKey());
-        assert l != null;
-        boolean wasPresent = l.remove(c);
-        assert wasPresent;
-    }
-
-    private void
-    putConnection(HttpConnection c,
-                  HashMap<CacheKey,LinkedList<HttpConnection>> pool) {
-        CacheKey key = c.cacheKey();
-        LinkedList<HttpConnection> l = pool.get(key);
-        if (l == null) {
-            l = new LinkedList<>();
-            pool.put(key, l);
-        }
-        l.add(c);
-    }
-
-    // only runs while entries exist in cache
-
-    class CacheCleaner extends Thread {
-
-        volatile boolean stopping;
-
-        CacheCleaner() {
-            super(null, null, "HTTP-Cache-cleaner", 0, false);
-            setDaemon(true);
-        }
-
-        synchronized boolean stopping() {
-            return stopping;
-        }
-
-        synchronized void stopCleaner() {
-            stopping = true;
-        }
-
-        @Override
-        public void run() {
-            while (!stopping()) {
-                try {
-                    Thread.sleep(3000);
-                } catch (InterruptedException e) {}
-                cleanCache();
-            }
-        }
-    }
-
-    synchronized void removeFromExpiryList(HttpConnection c) {
-        if (c == null) {
-            return;
-        }
-        ListIterator<ExpiryEntry> li = expiryList.listIterator();
-        while (li.hasNext()) {
-            ExpiryEntry e = li.next();
-            if (e.connection.equals(c)) {
-                li.remove();
-                return;
-            }
-        }
-        if (expiryList.isEmpty()) {
-            cleaner.stopCleaner();
-        }
-    }
-
-    private void cleanCache() {
-        long now = System.currentTimeMillis() / 1000;
-        LinkedList<HttpConnection> closelist = new LinkedList<>();
-
-        synchronized (this) {
-            ListIterator<ExpiryEntry> li = expiryList.listIterator();
-            while (li.hasNext()) {
-                ExpiryEntry entry = li.next();
-                if (entry.expiry <= now) {
-                    li.remove();
-                    HttpConnection c = entry.connection;
-                    closelist.add(c);
-                    if (c instanceof PlainHttpConnection) {
-                        removeFromPool(c, plainPool);
-                    } else {
-                        removeFromPool(c, sslPool);
-                    }
-                }
-            }
-        }
-        for (HttpConnection c : closelist) {
-            //System.out.println ("KAC: closing " + c);
-            c.close();
-        }
-    }
-
-    private synchronized void addToExpiryList(HttpConnection conn) {
-        long now = System.currentTimeMillis() / 1000;
-        long then = now + KEEP_ALIVE;
-
-        if (expiryList.isEmpty())
-            cleaner = new CacheCleaner();
-
-        ListIterator<ExpiryEntry> li = expiryList.listIterator();
-        while (li.hasNext()) {
-            ExpiryEntry entry = li.next();
-
-            if (then > entry.expiry) {
-                li.previous();
-                // insert here
-                li.add(new ExpiryEntry(conn, then));
-                return;
-            }
-        }
-        // first element of list
-        expiryList.add(new ExpiryEntry(conn, then));
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/ContinuationFrame.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-
-class ContinuationFrame extends HeaderFrame {
-
-    public static final int TYPE = 0x9;
-
-    ContinuationFrame() {
-        type = TYPE;
-    }
-
-    @Override
-    void readIncomingImpl(ByteBufferConsumer bc) throws IOException {
-        headerBlocks = bc.getBuffers(length);
-    }
-
-    @Override
-    void writeOutgoing(ByteBufferGenerator bg) {
-        super.writeOutgoing(bg);
-        for (int i=0; i<headerBlocks.length; i++) {
-            bg.addByteBuffer(headerBlocks[i]);
-        }
-    }
-
-    @Override
-    public boolean endHeaders() {
-        return getFlag(END_HEADERS);
-    }
-
-    @Override
-    void computeLength() {
-        length = headerLength;
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/CookieFilter.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.net.CookieManager;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-class CookieFilter implements HeaderFilter {
-
-    final HttpClientImpl client;
-    final CookieManager cookieMan;
-
-    CookieFilter(HttpClientImpl client) {
-        this.client = client;
-        this.cookieMan = client.cookieManager().orElseThrow(
-                () -> new IllegalArgumentException("no cookie manager"));
-    }
-
-    @Override
-    public void request(HttpRequestImpl r) throws IOException {
-        Map<String,List<String>> userheaders, cookies;
-        userheaders = r.getUserHeaders().map();
-        cookies = cookieMan.get(r.uri(), userheaders);
-        // add the returned cookies
-        HttpHeadersImpl systemHeaders = r.getSystemHeaders();
-        Set<String> keys = cookies.keySet();
-        for (String hdrname : keys) {
-            List<String> vals = cookies.get(hdrname);
-            for (String val : vals) {
-                systemHeaders.addHeader(hdrname, val);
-            }
-        }
-    }
-
-    @Override
-    public HttpRequestImpl response(HttpResponseImpl r) throws IOException {
-        HttpHeaders hdrs = r.headers();
-        cookieMan.put(r.uri(), hdrs.map());
-        return null;
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/DataFrame.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-class DataFrame extends Http2Frame {
-
-    public final static int TYPE = 0x0;
-
-    DataFrame() {
-        type = TYPE;
-    }
-
-    // Flags
-    public static final int END_STREAM = 0x1;
-    public static final int PADDED = 0x8;
-
-    int padLength;
-    int dataLength;
-    ByteBuffer[] data;
-
-    public void setData(ByteBuffer[] data) {
-        this.data = data;
-        setDataLength();
-    }
-
-    @Override
-    String flagAsString(int flag) {
-        switch (flag) {
-        case END_STREAM:
-            return "END_STREAM";
-        case PADDED:
-            return "PADDED";
-        }
-        return super.flagAsString(flag);
-    }
-
-    public synchronized void setData(ByteBuffer data) {
-        ByteBuffer[] bb;
-        if (data == null) {
-            bb = new ByteBuffer[0];
-        } else {
-            bb = new ByteBuffer[1];
-            bb[0] = data;
-        }
-        setData(bb);
-    }
-
-    public synchronized ByteBuffer[] getData() {
-        return data;
-    }
-
-    private void setDataLength() {
-        int len = 0;
-        for (ByteBuffer buf : data) {
-            len += buf.remaining();
-        }
-        dataLength = len;
-    }
-
-    @Override
-    void readIncomingImpl(ByteBufferConsumer bc) throws IOException {
-        if ((flags & PADDED) != 0) {
-            padLength = bc.getByte();
-            dataLength = length - (padLength + 1);
-        } else {
-            dataLength = length;
-        }
-        data = bc.getBuffers(dataLength);
-    }
-
-    int getPadLength() {
-        return padLength;
-    }
-
-    int getDataLength() {
-        return dataLength;
-    }
-
-    @Override
-    void writeOutgoing(ByteBufferGenerator bg) {
-        super.writeOutgoing(bg);
-        if ((flags & PADDED) != 0) {
-            ByteBuffer buf = bg.getBuffer(1);
-            buf.put((byte)getPadLength());
-        }
-        for (int i=0; i<data.length; i++) {
-            bg.addByteBuffer(data[i]);
-        }
-        if ((flags & PADDED) != 0) {
-            bg.addPadding(padLength);
-        }
-    }
-
-    @Override
-    void computeLength() {
-        length = dataLength;
-        if ((flags & PADDED) != 0) {
-            length += (1 + padLength);
-        }
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/ErrorFrame.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-abstract class ErrorFrame extends Http2Frame {
-
-    // error codes
-    public static final int NO_ERROR = 0x0;
-    public static final int PROTOCOL_ERROR = 0x1;
-    public static final int INTERNAL_ERROR = 0x2;
-    public static final int FLOW_CONTROL_ERROR = 0x3;
-    public static final int SETTINGS_TIMEOUT = 0x4;
-    public static final int STREAM_CLOSED = 0x5;
-    public static final int FRAME_SIZE_ERROR = 0x6;
-    public static final int REFUSED_STREAM = 0x7;
-    public static final int CANCEL = 0x8;
-    public static final int COMPRESSION_ERROR = 0x9;
-    public static final int CONNECT_ERROR = 0xa;
-    public static final int ENHANCE_YOUR_CALM = 0xb;
-    public static final int INADEQUATE_SECURITY = 0xc;
-    public static final int HTTP_1_1_REQUIRED = 0xd;
-    static final int LAST_ERROR = 0xd;
-
-    static final String[] errorStrings = {
-        "Not an error",
-        "Protocol error",
-        "Internal error",
-        "Flow control error",
-        "Settings timeout",
-        "Stream is closed",
-        "Frame size error",
-        "Stream not processed",
-        "Stream cancelled",
-        "Compression state not updated",
-        "TCP Connection error on CONNECT",
-        "Processing capacity exceeded",
-        "Negotiated TLS parameters not acceptable",
-        "Use HTTP/1.1 for request"
-    };
-
-    public static String stringForCode(int code) {
-        if (code < 0)
-            throw new IllegalArgumentException();
-
-        if (code > LAST_ERROR) {
-            return "Error: " + Integer.toString(code);
-        } else {
-            return errorStrings[code];
-        }
-    }
-
-    int errorCode;
-
-    @Override
-    public String toString() {
-        return super.toString() + " Error: " + stringForCode(errorCode);
-    }
-
-    public int getErrorCode() {
-        return this.errorCode;
-    }
-
-    public void setErrorCode(int errorCode) {
-        this.errorCode = errorCode;
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/Exchange.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,398 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.net.InetSocketAddress;
-import java.net.SocketPermission;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URLPermission;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-
-/**
- * One request/response exchange (handles 100/101 intermediate response also).
- * depth field used to track number of times a new request is being sent
- * for a given API request. If limit exceeded exception is thrown.
- *
- * Security check is performed here:
- * - uses AccessControlContext captured at API level
- * - checks for appropriate URLPermission for request
- * - if permission allowed, grants equivalent SocketPermission to call
- * - in case of direct HTTP proxy, checks additionally for access to proxy
- *    (CONNECT proxying uses its own Exchange, so check done there)
- *
- */
-class Exchange {
-
-    final HttpRequestImpl request;
-    final HttpClientImpl client;
-    ExchangeImpl exchImpl;
-    HttpResponseImpl response;
-    final List<SocketPermission> permissions = new LinkedList<>();
-    AccessControlContext acc;
-    boolean upgrading; // to HTTP/2
-
-    Exchange(HttpRequestImpl request) {
-        this.request = request;
-        this.upgrading = false;
-        this.client = request.client();
-    }
-
-    /* If different AccessControlContext to be used  */
-    Exchange(HttpRequestImpl request, AccessControlContext acc) {
-        this.request = request;
-        this.acc = acc;
-        this.upgrading = false;
-        this.client = request.client();
-    }
-
-    public HttpRequestImpl request() {
-        return request;
-    }
-
-    public HttpResponseImpl response() throws IOException, InterruptedException {
-        response = responseImpl(null);
-        return response;
-    }
-
-    public void cancel() {
-        if (exchImpl != null)
-            exchImpl.cancel();
-    }
-
-    public void h2Upgrade() {
-        upgrading = true;
-        request.setH2Upgrade();
-    }
-
-    static final SocketPermission[] SOCKET_ARRAY = new SocketPermission[0];
-
-    HttpResponseImpl responseImpl(HttpConnection connection)
-        throws IOException, InterruptedException
-    {
-        if (acc == null) {
-            acc = request.getAccessControlContext();
-        }
-        SecurityException e = securityCheck(acc);
-        if (e != null)
-            throw e;
-
-        if (permissions.size() > 0) {
-            try {
-                return AccessController.doPrivileged(
-                        (PrivilegedExceptionAction<HttpResponseImpl>)() ->
-                             responseImpl0(connection),
-                        null,
-                        permissions.toArray(SOCKET_ARRAY));
-            } catch (Throwable ee) {
-                if (ee instanceof PrivilegedActionException) {
-                    ee = ee.getCause();
-                }
-                if (ee instanceof IOException)
-                    throw (IOException)ee;
-                else
-                    throw new RuntimeException(ee); // TODO: fix
-            }
-        } else {
-            return responseImpl0(connection);
-        }
-    }
-
-    private HttpResponseImpl responseImpl0(HttpConnection connection)
-        throws IOException, InterruptedException
-    {
-        exchImpl = ExchangeImpl.get(this, connection);
-        if (request.expectContinue()) {
-            request.addSystemHeader("Expect", "100-Continue");
-            exchImpl.sendHeadersOnly();
-            HttpResponseImpl resp = exchImpl.getResponse();
-            Utils.logResponse(resp);
-            if (resp.statusCode() != 100) {
-                return resp;
-            }
-            exchImpl.sendBody();
-            return exchImpl.getResponse();
-        } else {
-            exchImpl.sendRequest();
-            HttpResponseImpl resp = exchImpl.getResponse();
-            Utils.logResponse(resp);
-            return checkForUpgrade(resp, exchImpl);
-        }
-    }
-
-    // Completed HttpResponse will be null if response succeeded
-    // will be a non null responseAsync if expect continue returns an error
-
-    public CompletableFuture<HttpResponseImpl> responseAsync(Void v) {
-        return responseAsyncImpl(null);
-    }
-
-    CompletableFuture<HttpResponseImpl> responseAsyncImpl(HttpConnection connection) {
-        if (acc == null) {
-            acc = request.getAccessControlContext();
-        }
-        SecurityException e = securityCheck(acc);
-        if (e != null) {
-            return CompletableFuture.failedFuture(e);
-        }
-        if (permissions.size() > 0) {
-            return AccessController.doPrivileged(
-                    (PrivilegedAction<CompletableFuture<HttpResponseImpl>>)() ->
-                        responseAsyncImpl0(connection),
-                    null,
-                    permissions.toArray(SOCKET_ARRAY));
-        } else {
-            return responseAsyncImpl0(connection);
-        }
-    }
-
-    CompletableFuture<HttpResponseImpl> responseAsyncImpl0(HttpConnection connection) {
-        try {
-            exchImpl = ExchangeImpl.get(this, connection);
-        } catch (IOException | InterruptedException e) {
-            return CompletableFuture.failedFuture(e);
-        }
-        if (request.expectContinue()) {
-            request.addSystemHeader("Expect", "100-Continue");
-            return exchImpl.sendHeadersAsync()
-                    .thenCompose(exchImpl::getResponseAsync)
-                    .thenCompose((HttpResponseImpl r1) -> {
-                        int rcode = r1.statusCode();
-                        CompletableFuture<HttpResponseImpl> cf =
-                                checkForUpgradeAsync(r1, exchImpl);
-                        if (cf != null)
-                            return cf;
-                        if (rcode == 100) {
-                            return exchImpl.sendBodyAsync()
-                                .thenCompose(exchImpl::getResponseAsync)
-                                .thenApply((r) -> {
-                                    Utils.logResponse(r);
-                                    return r;
-                                });
-                        } else {
-                            Exchange.this.response = r1;
-                            Utils.logResponse(r1);
-                            return CompletableFuture.completedFuture(r1);
-                        }
-                    });
-        } else {
-            return exchImpl
-                .sendRequestAsync()
-                .thenCompose(exchImpl::getResponseAsync)
-                .thenCompose((HttpResponseImpl r1) -> {
-                    int rcode = r1.statusCode();
-                    CompletableFuture<HttpResponseImpl> cf =
-                            checkForUpgradeAsync(r1, exchImpl);
-                    if (cf != null) {
-                        return cf;
-                    } else {
-                        Exchange.this.response = r1;
-                        Utils.logResponse(r1);
-                        return CompletableFuture.completedFuture(r1);
-                    }
-                })
-                .thenApply((HttpResponseImpl response) -> {
-                    this.response = response;
-                    Utils.logResponse(response);
-                    return response;
-                });
-        }
-    }
-
-    // if this response was received in reply to an upgrade
-    // then create the Http2Connection from the HttpConnection
-    // initialize it and wait for the real response on a newly created Stream
-
-    private CompletableFuture<HttpResponseImpl>
-    checkForUpgradeAsync(HttpResponseImpl resp,
-                         ExchangeImpl ex) {
-        int rcode = resp.statusCode();
-        if (upgrading && (rcode == 101)) {
-            Http1Exchange e = (Http1Exchange)ex;
-            // check for 101 switching protocols
-            return e.responseBodyAsync(HttpResponse.ignoreBody())
-                .thenCompose((Void v) ->
-                     Http2Connection.createAsync(e.connection(),
-                                                 client.client2(),
-                                                 this)
-                        .thenCompose((Http2Connection c) -> {
-                            c.putConnection();
-                            Stream s = c.getStream(1);
-                            exchImpl = s;
-                            return s.getResponseAsync(null);
-                        })
-                );
-        }
-        return CompletableFuture.completedFuture(resp);
-    }
-
-    private HttpResponseImpl checkForUpgrade(HttpResponseImpl resp,
-                                             ExchangeImpl ex)
-        throws IOException, InterruptedException
-    {
-        int rcode = resp.statusCode();
-        if (upgrading && (rcode == 101)) {
-            Http1Exchange e = (Http1Exchange) ex;
-            // must get connection from Http1Exchange
-            e.responseBody(HttpResponse.ignoreBody(), false);
-            Http2Connection h2con = new Http2Connection(e.connection(),
-                                                        client.client2(),
-                                                        this);
-            h2con.putConnection();
-            Stream s = h2con.getStream(1);
-            exchImpl = s;
-            return s.getResponse();
-        }
-        return resp;
-    }
-
-
-    <T> T responseBody(HttpResponse.BodyProcessor<T> processor) {
-        try {
-            return exchImpl.responseBody(processor);
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-    }
-
-
-
-    <T> CompletableFuture<T> responseBodyAsync(HttpResponse.BodyProcessor<T> processor) {
-        return exchImpl.responseBodyAsync(processor);
-    }
-
-    private URI getURIForSecurityCheck() {
-        URI u;
-        String method = request.method();
-        InetSocketAddress authority = request.authority();
-        URI uri = request.uri();
-
-        // CONNECT should be restricted at API level
-        if (method.equalsIgnoreCase("CONNECT")) {
-            try {
-                u = new URI("socket",
-                             null,
-                             authority.getHostString(),
-                             authority.getPort(),
-                             null,
-                             null,
-                             null);
-            } catch (URISyntaxException e) {
-                throw new InternalError(e); // shouldn't happen
-            }
-        } else {
-            u = uri;
-        }
-        return u;
-    }
-
-    /**
-     * Do the security check and return any exception.
-     * Return null if no check needed or passes.
-     *
-     * Also adds any generated permissions to the "permissions" list.
-     */
-    private SecurityException securityCheck(AccessControlContext acc) {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm == null) {
-            return null;
-        }
-
-        String method = request.method();
-        HttpHeaders userHeaders = request.getUserHeaders();
-        URI u = getURIForSecurityCheck();
-        URLPermission p = Utils.getPermission(u, method, userHeaders.map());
-
-        try {
-            assert acc != null;
-            sm.checkPermission(p, acc);
-            permissions.add(getSocketPermissionFor(u));
-        } catch (SecurityException e) {
-            return e;
-        }
-        InetSocketAddress proxy = request.proxy();
-        if (proxy != null) {
-            // may need additional check
-            if (!method.equals("CONNECT")) {
-                // a direct http proxy. Need to check access to proxy
-                try {
-                    u = new URI("socket", null, proxy.getHostString(),
-                        proxy.getPort(), null, null, null);
-                } catch (URISyntaxException e) {
-                    throw new InternalError(e); // shouldn't happen
-                }
-                p = new URLPermission(u.toString(), "CONNECT");
-                try {
-                    sm.checkPermission(p, acc);
-                } catch (SecurityException e) {
-                    permissions.clear();
-                    return e;
-                }
-                String sockperm = proxy.getHostString() +
-                        ":" + Integer.toString(proxy.getPort());
-
-                permissions.add(new SocketPermission(sockperm, "connect,resolve"));
-            }
-        }
-        return null;
-    }
-
-    private static SocketPermission getSocketPermissionFor(URI url) {
-        if (System.getSecurityManager() == null)
-            return null;
-
-        StringBuilder sb = new StringBuilder();
-        String host = url.getHost();
-        sb.append(host);
-        int port = url.getPort();
-        if (port == -1) {
-            String scheme = url.getScheme();
-            if ("http".equals(scheme)) {
-                sb.append(":80");
-            } else { // scheme must be https
-                sb.append(":443");
-            }
-        } else {
-            sb.append(':')
-              .append(Integer.toString(port));
-        }
-        String target = sb.toString();
-        return new SocketPermission(target, "connect");
-    }
-
-    AccessControlContext getAccessControlContext() {
-        return acc;
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/ExchangeImpl.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.util.concurrent.CompletableFuture;
-import static java.net.http.HttpClient.Version.HTTP_1_1;
-
-/**
- * Splits request so that headers and body can be sent separately with optional
- * (multiple) responses in between (e.g. 100 Continue). Also request and
- * response always sent/received in different calls.
- *
- * Synchronous and asynchronous versions of each method are provided.
- *
- * Separate implementations of this class exist for HTTP/1.1 and HTTP/2
- *      Http1Exchange   (HTTP/1.1)
- *      Stream          (HTTP/2)
- *
- * These implementation classes are where work is allocated to threads.
- */
-abstract class ExchangeImpl {
-
-    final Exchange exchange;
-
-    ExchangeImpl(Exchange e) {
-        this.exchange = e;
-    }
-
-    /**
-     * Initiates a new exchange and assigns it to a connection if one exists
-     * already. connection usually null.
-     */
-    static ExchangeImpl get(Exchange exchange, HttpConnection connection)
-        throws IOException, InterruptedException
-    {
-        HttpRequestImpl req = exchange.request();
-        if (req.version() == HTTP_1_1) {
-            return new Http1Exchange(exchange, connection);
-        } else {
-            Http2ClientImpl c2 = exchange.request().client().client2(); // TODO: improve
-            HttpRequestImpl request = exchange.request();
-            Http2Connection c = c2.getConnectionFor(request);
-            if (c == null) {
-                // no existing connection. Send request with HTTP 1 and then
-                // upgrade if successful
-                ExchangeImpl ex = new Http1Exchange(exchange, connection);
-                exchange.h2Upgrade();
-                return ex;
-            }
-            return c.createStream(exchange);
-        }
-    }
-
-    /* The following methods have separate HTTP/1.1 and HTTP/2 implementations */
-
-    /**
-     * Sends the request headers only. May block until all sent.
-     */
-    abstract void sendHeadersOnly() throws IOException, InterruptedException;
-
-    /**
-     * Gets response headers by blocking if necessary. This may be an
-     * intermediate response (like 101) or a final response 200 etc.
-     */
-    abstract HttpResponseImpl getResponse() throws IOException;
-
-    /**
-     * Sends a request body after request headers.
-     */
-    abstract void sendBody() throws IOException, InterruptedException;
-
-    /**
-     * Sends the entire request (headers and body) blocking.
-     */
-    abstract void sendRequest() throws IOException, InterruptedException;
-
-    /**
-     * Asynchronous version of sendHeaders().
-     */
-    abstract CompletableFuture<Void> sendHeadersAsync();
-
-    /**
-     * Asynchronous version of getResponse().  Requires void parameter for
-     * CompletableFuture chaining.
-     */
-    abstract CompletableFuture<HttpResponseImpl> getResponseAsync(Void v);
-
-    /**
-     * Asynchronous version of sendBody().
-     */
-    abstract CompletableFuture<Void> sendBodyAsync();
-
-    /**
-     * Cancels a request.  Not currently exposed through API.
-     */
-    abstract void cancel();
-
-    /**
-     * Asynchronous version of sendRequest().
-     */
-    abstract CompletableFuture<Void> sendRequestAsync();
-
-    abstract <T> T responseBody(HttpResponse.BodyProcessor<T> processor)
-        throws IOException;
-
-    /**
-     * Asynchronous version of responseBody().
-     */
-    abstract <T> CompletableFuture<T>
-    responseBodyAsync(HttpResponse.BodyProcessor<T> processor);
-}
--- a/src/java.httpclient/share/classes/java/net/http/ExecutorWrapper.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.function.Supplier;
-
-/**
- * Wraps the supplied user ExecutorService.
- *
- * 1) when a Security manager set, the correct access control context
- *    is used to execute task
- *
- * 2) memory fence implemented
- */
-class ExecutorWrapper {
-
-    final ExecutorService userExecutor; // the actual executor service used
-    final Executor executor;
-
-    public static ExecutorWrapper wrap(ExecutorService userExecutor) {
-        return new ExecutorWrapper(userExecutor);
-    }
-
-    /**
-     * Returns a dummy ExecutorWrapper which uses the calling thread
-     */
-    public static ExecutorWrapper callingThread() {
-        return new ExecutorWrapper();
-    }
-
-    private ExecutorWrapper(ExecutorService userExecutor) {
-        // used for executing in calling thread
-        this.userExecutor = userExecutor;
-        this.executor = userExecutor;
-    }
-
-    private ExecutorWrapper() {
-        this.userExecutor = null;
-        this.executor = (Runnable command) -> {
-            command.run();
-        };
-    }
-
-    public ExecutorService userExecutor() {
-        return userExecutor;
-    }
-
-    public synchronized void synchronize() {}
-
-    public void execute(Runnable r, Supplier<AccessControlContext> ctxSupplier) {
-        synchronize();
-        Runnable r1 = () -> {
-            try {
-                r.run();
-            } catch (Throwable t) {
-                Log.logError(t);
-            }
-        };
-
-        if (ctxSupplier != null && System.getSecurityManager() != null) {
-            AccessControlContext acc = ctxSupplier.get();
-            if (acc == null) {
-                throw new InternalError();
-            }
-            AccessController.doPrivilegedWithCombiner(
-                (PrivilegedAction<Void>)() -> {
-                    executor.execute(r1); // all throwables must be caught
-                    return null;
-                }, acc);
-        } else {
-            executor.execute(r1); // all throwables must be caught
-        }
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/FilterFactory.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.util.LinkedList;
-import java.util.List;
-
-class FilterFactory {
-
-    final LinkedList<Class<? extends HeaderFilter>> filterClasses = new LinkedList<>();
-
-    public void addFilter(Class<? extends HeaderFilter> type) {
-        filterClasses.add(type);
-    }
-
-    List<HeaderFilter> getFilterChain() {
-        List<HeaderFilter> l = new LinkedList<>();
-        for (Class<? extends HeaderFilter> clazz : filterClasses) {
-            try {
-                @SuppressWarnings("deprecation")
-                HeaderFilter headerFilter = clazz.newInstance();
-                l.add(headerFilter);
-            } catch (ReflectiveOperationException e) {
-                throw new InternalError(e);
-            }
-        }
-        return l;
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/FrameReader.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.nio.ByteBuffer;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Represents one frame. May be initialized with a leftover buffer from previous
- * frame. Call {@code haveFrame()} to determine if buffers contains at least one
- * frame. If false, the obtain another buffer and call {@code}input(ByteBuffer)}.
- * There may be additional bytes at end of the frame list.
- */
-class FrameReader {
-
-    final List<ByteBuffer> buffers;
-
-    FrameReader() {
-        buffers = new LinkedList<>();
-    }
-
-    FrameReader(FrameReader that) {
-        this.buffers = that.buffers;
-    }
-
-    FrameReader(ByteBuffer remainder) {
-        buffers = new LinkedList<>();
-        if (remainder != null) {
-            buffers.add(remainder);
-        }
-    }
-
-    public synchronized void input(ByteBuffer buffer) {
-        buffers.add(buffer);
-    }
-
-    public synchronized boolean haveFrame() {
-        //buffers = Utils.superCompact(buffers, () -> ByteBuffer.allocate(Utils.BUFSIZE));
-        int size = 0;
-        for (ByteBuffer buffer : buffers) {
-            size += buffer.remaining();
-        }
-        if (size < 3) {
-            return false; // don't have length yet
-        }
-        // we at least have length field
-        int length = 0;
-        int j = 0;
-        ByteBuffer b = buffers.get(j);
-        b.mark();
-        for (int i=0; i<3; i++) {
-            while (!b.hasRemaining()) {
-                b.reset();
-                b = buffers.get(++j);
-                b.mark();
-            }
-            length = (length << 8) + (b.get() & 0xff);
-        }
-        b.reset();
-        return (size >= length + 9); // frame length
-    }
-
-    synchronized List<ByteBuffer> frame() {
-        return buffers;
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/GoAwayFrame.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-class GoAwayFrame extends ErrorFrame {
-
-    GoAwayFrame() {
-        type = TYPE;
-    }
-
-    int lastStream;
-    byte[] debugData = new byte[0];
-
-    public static final int TYPE = 0x7;
-
-    // Flags
-    public static final int ACK = 0x1;
-
-    public void setDebugData(byte[] debugData) {
-        this.debugData = debugData;
-    }
-
-    @Override
-    public String toString() {
-        return super.toString() + " Debugdata: " + new String(debugData);
-    }
-
-    @Override
-    String flagAsString(int flag) {
-        switch (flag) {
-        case ACK:
-            return "ACK";
-        }
-        return super.flagAsString(flag);
-    }
-
-    public void setLastStream(int lastStream) {
-        this.lastStream = lastStream;
-    }
-
-    public int getLastStream() {
-        return this.lastStream;
-    }
-
-    public byte[] getDebugData() {
-        return debugData;
-    }
-
-    @Override
-    void readIncomingImpl(ByteBufferConsumer bc) throws IOException {
-        if (length < 8) {
-            throw new IOException("Invalid GoAway frame");
-        }
-        lastStream = bc.getInt() & 0x7fffffff;
-        errorCode = bc.getInt();
-        //debugData = bc.getBytes(8);
-        int datalen = length - 8;
-        if (datalen > 0) {
-            debugData = bc.getBytes(datalen);
-            Log.logError("GoAway debugData " + new String(debugData));
-        }
-    }
-
-    @Override
-    void writeOutgoing(ByteBufferGenerator bg) {
-        super.writeOutgoing(bg);
-        ByteBuffer buf = bg.getBuffer(length);
-        buf.putInt(lastStream);
-        buf.putInt(errorCode);
-        if (length > 8) {
-            buf.put(debugData);
-        }
-    }
-
-    @Override
-    void computeLength() {
-        length = 8 + debugData.length;
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/HeaderFilter.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-
-/**
- * A header filter that can examine or modify, typically system headers for
- * requests before they are sent, and responses before they are returned to the
- * user. Some ability to resend requests is provided.
- *
- */
-interface HeaderFilter {
-
-    void request(HttpRequestImpl r) throws IOException;
-
-    /**
-     * Returns null if response ok to be given to user.  Non null is a request
-     * that must be resent and its response given to user. If impl throws an
-     * exception that is returned to user instead.
-     */
-    HttpRequestImpl response(HttpResponseImpl r) throws IOException;
-}
--- a/src/java.httpclient/share/classes/java/net/http/HeaderFrame.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.nio.ByteBuffer;
-
-/**
- * Either a HeadersFrame or a ContinuationFrame
- */
-abstract class HeaderFrame extends Http2Frame {
-
-    int offset;
-    int number;
-    int headerLength;
-    ByteBuffer[] headerBlocks;
-
-    public static final int END_HEADERS = 0x4;
-
-    @Override
-    String flagAsString(int flag) {
-        switch (flag) {
-        case END_HEADERS:
-            return "END_HEADERS";
-        }
-        return super.flagAsString(flag);
-    }
-
-    /**
-     * Sets the array of hpack encoded ByteBuffers
-     */
-    public void setHeaderBlock(ByteBuffer bufs[], int offset, int number) {
-        this.headerBlocks = bufs;
-        this.offset = offset;
-        this.number = number;
-        int length = 0;
-        for (int i=offset; i<offset+number; i++) {
-            length += headerBlocks[i].remaining();
-        }
-        this.headerLength = length;
-    }
-
-    public void setHeaderBlock(ByteBuffer bufs[]) {
-        setHeaderBlock(bufs, 0, bufs.length);
-    }
-
-    public ByteBuffer[] getHeaderBlock() {
-        return headerBlocks;
-    }
-
-    /**
-     * Returns true if this block is the final block of headers
-     */
-    public abstract boolean endHeaders();
-
-}
--- a/src/java.httpclient/share/classes/java/net/http/HeaderParser.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,247 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.NoSuchElementException;
-
-/* This is useful for the nightmare of parsing multi-part HTTP/RFC822 headers
- * sensibly:
- * From a String like: 'timeout=15, max=5'
- * create an array of Strings:
- * { {"timeout", "15"},
- *   {"max", "5"}
- * }
- * From one like: 'Basic Realm="FuzzFace" Foo="Biz Bar Baz"'
- * create one like (no quotes in literal):
- * { {"basic", null},
- *   {"realm", "FuzzFace"}
- *   {"foo", "Biz Bar Baz"}
- * }
- * keys are converted to lower case, vals are left as is....
- */
-class HeaderParser {
-
-    /* table of key/val pairs */
-    String raw;
-    String[][] tab;
-    int nkeys;
-    int asize = 10; // initial size of array is 10
-
-    public HeaderParser(String raw) {
-        this.raw = raw;
-        tab = new String[asize][2];
-        parse();
-    }
-
-    private HeaderParser () { }
-
-    /**
-     * Creates a new HeaderParser from this, whose keys (and corresponding
-     * values) range from "start" to "end-1"
-     */
-    public HeaderParser subsequence(int start, int end) {
-        if (start == 0 && end == nkeys) {
-            return this;
-        }
-        if (start < 0 || start >= end || end > nkeys)
-            throw new IllegalArgumentException("invalid start or end");
-        HeaderParser n = new HeaderParser();
-        n.tab = new String [asize][2];
-        n.asize = asize;
-        System.arraycopy (tab, start, n.tab, 0, (end-start));
-        n.nkeys= (end-start);
-        return n;
-    }
-
-    private void parse() {
-
-        if (raw != null) {
-            raw = raw.trim();
-            char[] ca = raw.toCharArray();
-            int beg = 0, end = 0, i = 0;
-            boolean inKey = true;
-            boolean inQuote = false;
-            int len = ca.length;
-            while (end < len) {
-                char c = ca[end];
-                if ((c == '=') && !inQuote) { // end of a key
-                    tab[i][0] = new String(ca, beg, end-beg).toLowerCase(Locale.US);
-                    inKey = false;
-                    end++;
-                    beg = end;
-                } else if (c == '\"') {
-                    if (inQuote) {
-                        tab[i++][1]= new String(ca, beg, end-beg);
-                        inQuote=false;
-                        do {
-                            end++;
-                        } while (end < len && (ca[end] == ' ' || ca[end] == ','));
-                        inKey=true;
-                        beg=end;
-                    } else {
-                        inQuote=true;
-                        end++;
-                        beg=end;
-                    }
-                } else if (c == ' ' || c == ',') { // end key/val, of whatever we're in
-                    if (inQuote) {
-                        end++;
-                        continue;
-                    } else if (inKey) {
-                        tab[i++][0] = (new String(ca, beg, end-beg)).toLowerCase(Locale.US);
-                    } else {
-                        tab[i++][1] = (new String(ca, beg, end-beg));
-                    }
-                    while (end < len && (ca[end] == ' ' || ca[end] == ',')) {
-                        end++;
-                    }
-                    inKey = true;
-                    beg = end;
-                } else {
-                    end++;
-                }
-                if (i == asize) {
-                    asize = asize * 2;
-                    String[][] ntab = new String[asize][2];
-                    System.arraycopy (tab, 0, ntab, 0, tab.length);
-                    tab = ntab;
-                }
-            }
-            // get last key/val, if any
-            if (--end > beg) {
-                if (!inKey) {
-                    if (ca[end] == '\"') {
-                        tab[i++][1] = (new String(ca, beg, end-beg));
-                    } else {
-                        tab[i++][1] = (new String(ca, beg, end-beg+1));
-                    }
-                } else {
-                    tab[i++][0] = (new String(ca, beg, end-beg+1)).toLowerCase();
-                }
-            } else if (end == beg) {
-                if (!inKey) {
-                    if (ca[end] == '\"') {
-                        tab[i++][1] = String.valueOf(ca[end-1]);
-                    } else {
-                        tab[i++][1] = String.valueOf(ca[end]);
-                    }
-                } else {
-                    tab[i++][0] = String.valueOf(ca[end]).toLowerCase();
-                }
-            }
-            nkeys=i;
-        }
-    }
-
-    public String findKey(int i) {
-        if (i < 0 || i > asize)
-            return null;
-        return tab[i][0];
-    }
-
-    public String findValue(int i) {
-        if (i < 0 || i > asize)
-            return null;
-        return tab[i][1];
-    }
-
-    public String findValue(String key) {
-        return findValue(key, null);
-    }
-
-    public String findValue(String k, String Default) {
-        if (k == null)
-            return Default;
-        k = k.toLowerCase(Locale.US);
-        for (int i = 0; i < asize; ++i) {
-            if (tab[i][0] == null) {
-                return Default;
-            } else if (k.equals(tab[i][0])) {
-                return tab[i][1];
-            }
-        }
-        return Default;
-    }
-
-    class ParserIterator implements Iterator<String> {
-        int index;
-        boolean returnsValue; // or key
-
-        ParserIterator (boolean returnValue) {
-            returnsValue = returnValue;
-        }
-        @Override
-        public boolean hasNext () {
-            return index<nkeys;
-        }
-        @Override
-        public String next () {
-            if (index >= nkeys)
-                throw new NoSuchElementException();
-            return tab[index++][returnsValue?1:0];
-        }
-    }
-
-    public Iterator<String> keys () {
-        return new ParserIterator (false);
-    }
-
-    public Iterator<String> values () {
-        return new ParserIterator (true);
-    }
-
-    @Override
-    public String toString () {
-        Iterator<String> k = keys();
-        StringBuilder sb = new StringBuilder();
-        sb.append("{size=").append(asize).append(" nkeys=").append(nkeys)
-                .append(' ');
-        for (int i=0; k.hasNext(); i++) {
-            String key = k.next();
-            String val = findValue (i);
-            if (val != null && "".equals (val)) {
-                val = null;
-            }
-            sb.append(" {").append(key).append(val == null ? "" : "," + val)
-                    .append('}');
-            if (k.hasNext()) {
-                sb.append (',');
-            }
-        }
-        sb.append (" }");
-        return sb.toString();
-    }
-
-    public int findInt(String k, int Default) {
-        try {
-            return Integer.parseInt(findValue(k, String.valueOf(Default)));
-        } catch (Throwable t) {
-            return Default;
-        }
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/HeadersFrame.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-class HeadersFrame extends HeaderFrame {
-
-    public final static int TYPE = 0x1;
-
-    // Flags
-    public static final int END_STREAM = 0x1;
-    public static final int PADDED = 0x8;
-    public static final int PRIORITY = 0x20;
-
-
-    int padLength;
-    int streamDependency;
-    int weight;
-    boolean exclusive;
-
-    HeadersFrame() {
-        type = TYPE;
-    }
-
-    @Override
-    String flagAsString(int flag) {
-        switch (flag) {
-            case END_STREAM:
-                return "END_STREAM";
-            case PADDED:
-                return "PADDED";
-            case PRIORITY:
-                return "PRIORITY";
-        }
-        return super.flagAsString(flag);
-    }
-
-    public void setPadLength(int padLength) {
-        this.padLength = padLength;
-        flags |= PADDED;
-    }
-
-    public void setPriority(int streamDependency, boolean exclusive, int weight) {
-        this.streamDependency = streamDependency;
-        this.exclusive = exclusive;
-        this.weight = weight;
-        this.flags |= PRIORITY;
-    }
-
-    public int getStreamDependency() {
-        return streamDependency;
-    }
-
-    public int getWeight() {
-        return weight;
-    }
-
-    @Override
-    public boolean endHeaders() {
-        return getFlag(END_HEADERS);
-    }
-
-    public boolean getExclusive() {
-        return exclusive;
-    }
-
-    @Override
-    void readIncomingImpl(ByteBufferConsumer bc) throws IOException {
-        if ((flags & PADDED) != 0) {
-            padLength = bc.getByte();
-        }
-        if ((flags & PRIORITY) != 0) {
-            int x = bc.getInt();
-            exclusive = (x & 0x80000000) != 0;
-            streamDependency = x & 0x7fffffff;
-            weight = bc.getByte();
-        }
-        headerLength = length - padLength;
-        headerBlocks = bc.getBuffers(headerLength);
-    }
-
-    @Override
-    void computeLength() {
-        int len = 0;
-        if ((flags & PADDED) != 0) {
-            len += (1 + padLength);
-        }
-        if ((flags & PRIORITY) != 0) {
-            len += 5;
-        }
-        len += headerLength;
-        this.length = len;
-    }
-
-    @Override
-    void writeOutgoing(ByteBufferGenerator bg) {
-        super.writeOutgoing(bg);
-        ByteBuffer buf = bg.getBuffer(6);
-        if ((flags & PADDED) != 0) {
-            buf.put((byte)padLength);
-        }
-        if ((flags & PRIORITY) != 0) {
-            int x = exclusive ? 1 << 31 + streamDependency : streamDependency;
-            buf.putInt(x);
-            buf.put((byte)weight);
-        }
-        for (int i=0; i<headerBlocks.length; i++) {
-            bg.addByteBuffer(headerBlocks[i]);
-        }
-        if ((flags & PADDED) != 0) {
-            bg.addPadding(padLength);
-        }
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/Http1Exchange.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,291 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.URI;
-import java.util.concurrent.CompletableFuture;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Encapsulates one HTTP/1.1 request/responseAsync exchange.
- */
-class Http1Exchange extends ExchangeImpl {
-
-    final HttpRequestImpl request;        // main request
-    final List<CompletableFuture<?>> operations; // used for cancel
-    final Http1Request requestAction;
-    volatile Http1Response response;
-    final HttpConnection connection;
-    final HttpClientImpl client;
-    final ExecutorWrapper executor;
-
-    @Override
-    public String toString() {
-        return request.toString();
-    }
-
-    HttpRequestImpl request() {
-        return request;
-    }
-
-    Http1Exchange(Exchange exchange, HttpConnection connection)
-        throws IOException
-    {
-        super(exchange);
-        this.request = exchange.request();
-        this.client = request.client();
-        this.executor = client.executorWrapper();
-        this.operations = Collections.synchronizedList(new LinkedList<>());
-        if (connection != null) {
-            this.connection = connection;
-        } else {
-            InetSocketAddress addr = Utils.getAddress(request);
-            this.connection = HttpConnection.getConnection(addr, request);
-        }
-        this.requestAction = new Http1Request(request, this.connection);
-    }
-
-
-    HttpConnection connection() {
-        return connection;
-    }
-
-    @Override
-    <T> T responseBody(HttpResponse.BodyProcessor<T> processor)
-        throws IOException
-    {
-        return responseBody(processor, true);
-    }
-
-    <T> T responseBody(HttpResponse.BodyProcessor<T> processor,
-                       boolean return2Cache)
-        throws IOException
-    {
-        try {
-            T body = response.readBody(processor, return2Cache);
-            return body;
-        } catch (Throwable t) {
-            connection.close();
-            throw t;
-        }
-    }
-
-    @Override
-    <T> CompletableFuture<T> responseBodyAsync(HttpResponse.BodyProcessor<T> processor) {
-        CompletableFuture<T> cf = new CompletableFuture<>();
-        request.client()
-               .executorWrapper()
-               .execute(() -> {
-                            try {
-                                T body = responseBody(processor);
-                                cf.complete(body);
-                            } catch (Throwable e) {
-                                cf.completeExceptionally(e);
-                            }
-                        },
-                        () -> response.response.getAccessControlContext()); // TODO: fix
-        return cf;
-    }
-
-    @Override
-    void sendHeadersOnly() throws IOException, InterruptedException {
-        try {
-            if (!connection.connected()) {
-                connection.connect();
-            }
-            requestAction.sendHeadersOnly();
-        } catch (Throwable e) {
-            connection.close();
-            throw e;
-        }
-    }
-
-    @Override
-    void sendBody() throws IOException {
-        try {
-            requestAction.continueRequest();
-        } catch (Throwable e) {
-            connection.close();
-            throw e;
-        }
-    }
-
-    @Override
-    HttpResponseImpl getResponse() throws IOException {
-        try {
-            response = new Http1Response(connection, this);
-            response.readHeaders();
-            return response.response();
-        } catch (Throwable t) {
-            connection.close();
-            throw t;
-        }
-    }
-
-    @Override
-    void sendRequest() throws IOException, InterruptedException {
-        try {
-            if (!connection.connected()) {
-                connection.connect();
-            }
-            requestAction.sendRequest();
-        } catch (Throwable t) {
-            connection.close();
-            throw t;
-        }
-    }
-
-    private void closeConnection() {
-        connection.close();
-    }
-
-    @Override
-    CompletableFuture<Void> sendHeadersAsync() {
-        if (!connection.connected()) {
-            CompletableFuture<Void> op = connection.connectAsync()
-                    .thenCompose(this::sendHdrsAsyncImpl)
-                    .whenComplete((Void b, Throwable t) -> {
-                        if (t != null)
-                            closeConnection();
-                    });
-            operations.add(op);
-            return op;
-        } else {
-            return sendHdrsAsyncImpl(null);
-        }
-    }
-
-    private CompletableFuture<Void> sendHdrsAsyncImpl(Void v) {
-        CompletableFuture<Void> cf = new CompletableFuture<>();
-        executor.execute(() -> {
-                            try {
-                                requestAction.sendHeadersOnly();
-                                cf.complete(null);
-                            } catch (Throwable e) {
-                                cf.completeExceptionally(e);
-                                connection.close();
-                            }
-                         },
-                request::getAccessControlContext);
-        operations.add(cf);
-        return cf;
-    }
-
-    /**
-     * Cancel checks to see if request and responseAsync finished already.
-     * If not it closes the connection and completes all pending operations
-     */
-    @Override
-    synchronized void cancel() {
-        if (requestAction != null && requestAction.finished()
-                && response != null && response.finished()) {
-            return;
-        }
-        connection.close();
-        IOException e = new IOException("Request cancelled");
-        int count = 0;
-        for (CompletableFuture<?> cf : operations) {
-            cf.completeExceptionally(e);
-            count++;
-        }
-        Log.logError("Http1Exchange.cancel: count=" + count);
-    }
-
-    CompletableFuture<HttpResponseImpl> getResponseAsyncImpl(Void v) {
-        CompletableFuture<HttpResponseImpl> cf = new CompletableFuture<>();
-        try {
-            response = new Http1Response(connection, Http1Exchange.this);
-            response.readHeaders();
-            cf.complete(response.response());
-        } catch (IOException e) {
-            cf.completeExceptionally(e);
-        }
-        return cf;
-    }
-
-    @Override
-    CompletableFuture<HttpResponseImpl> getResponseAsync(Void v) {
-        CompletableFuture<HttpResponseImpl> cf =
-            connection.whenReceivingResponse()
-                      .thenCompose(this::getResponseAsyncImpl);
-
-        operations.add(cf);
-        return cf;
-    }
-
-    @Override
-    CompletableFuture<Void> sendBodyAsync() {
-        final CompletableFuture<Void> cf = new CompletableFuture<>();
-        executor.execute(() -> {
-            try {
-                requestAction.continueRequest();
-                cf.complete(null);
-            } catch (Throwable e) {
-                cf.completeExceptionally(e);
-                connection.close();
-            }
-        }, request::getAccessControlContext);
-        operations.add(cf);
-        return cf;
-    }
-
-    @Override
-    CompletableFuture<Void> sendRequestAsync() {
-        CompletableFuture<Void> op;
-        if (!connection.connected()) {
-            op = connection.connectAsync()
-                .thenCompose(this::sendRequestAsyncImpl)
-                .whenComplete((Void v, Throwable t) -> {
-                    if (t != null) {
-                        closeConnection();
-                    }
-                });
-        } else {
-            op = sendRequestAsyncImpl(null);
-        }
-        operations.add(op);
-        return op;
-    }
-
-    CompletableFuture<Void> sendRequestAsyncImpl(Void v) {
-        CompletableFuture<Void> cf = new CompletableFuture<>();
-        executor.execute(() -> {
-            try {
-                requestAction.sendRequest();
-                cf.complete(null);
-            } catch (Throwable e) {
-                cf.completeExceptionally(e);
-                connection.close();
-            }
-        }, request::getAccessControlContext);
-        operations.add(cf);
-        return cf;
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/Http1Request.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,381 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.net.URI;
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.net.InetSocketAddress;
-import java.net.http.HttpConnection.Mode;
-import java.nio.charset.StandardCharsets;
-import java.util.function.LongConsumer;
-import static java.nio.charset.StandardCharsets.US_ASCII;
-
-/**
- *  A HTTP/1.1 request.
- *
- * send() -> Writes the request + body to the given channel, in one blocking
- * operation.
- */
-class Http1Request {
-
-    final HttpRequestImpl request;
-    final HttpConnection chan;
-    // Multiple buffers are used to hold different parts of request
-    // See line 206 and below for description
-    final ByteBuffer[] buffers;
-    final HttpRequest.BodyProcessor requestProc;
-    final HttpHeaders userHeaders;
-    final HttpHeadersImpl systemHeaders;
-    final LongConsumer flowController;
-    boolean streaming;
-    long contentLength;
-
-    Http1Request(HttpRequestImpl request, HttpConnection connection)
-        throws IOException
-    {
-        this.request = request;
-        this.chan = connection;
-        buffers = new ByteBuffer[5]; // TODO: check
-        this.requestProc = request.requestProcessor();
-        this.userHeaders = request.getUserHeaders();
-        this.systemHeaders = request.getSystemHeaders();
-        this.flowController = this::dummy;
-    }
-
-    private void logHeaders() throws IOException {
-        StringBuilder sb = new StringBuilder(256);
-        sb.append("REQUEST HEADERS:\r\n");
-        collectHeaders1(sb, request, systemHeaders);
-        collectHeaders1(sb, request, userHeaders);
-        Log.logHeaders(sb.toString());
-    }
-
-    private void dummy(long x) {
-        // not used in this class
-    }
-
-    private void collectHeaders0() throws IOException {
-        if (Log.headers()) {
-            logHeaders();
-        }
-        StringBuilder sb = new StringBuilder(256);
-        collectHeaders1(sb, request, systemHeaders);
-        collectHeaders1(sb, request, userHeaders);
-        sb.append("\r\n");
-        String headers = sb.toString();
-        buffers[1] = ByteBuffer.wrap(headers.getBytes(StandardCharsets.US_ASCII));
-    }
-
-    private void collectHeaders1(StringBuilder sb,
-                                 HttpRequestImpl request,
-                                 HttpHeaders headers)
-        throws IOException
-    {
-        Map<String,List<String>> h = headers.map();
-        Set<Map.Entry<String,List<String>>> entries = h.entrySet();
-
-        for (Map.Entry<String,List<String>> entry : entries) {
-            String key = entry.getKey();
-            List<String> values = entry.getValue();
-            for (String value : values) {
-                sb.append(key)
-                  .append(": ")
-                  .append(value)
-                  .append("\r\n");
-            }
-        }
-    }
-
-    private String getPathAndQuery(URI uri) {
-        String path = uri.getPath();
-        String query = uri.getQuery();
-        if (path == null || path.equals("")) {
-            path = "/";
-        }
-        if (query == null) {
-            query = "";
-        }
-        if (query.equals("")) {
-            return path;
-        } else {
-            return path + "?" + query;
-        }
-    }
-
-    private String authorityString(InetSocketAddress addr) {
-        return addr.getHostString() + ":" + addr.getPort();
-    }
-
-    private String hostString() {
-        URI uri = request.uri();
-        int port = uri.getPort();
-        String host = uri.getHost();
-
-        boolean defaultPort;
-        if (port == -1)
-            defaultPort = true;
-        else if (request.secure())
-            defaultPort = port == 443;
-        else
-            defaultPort = port == 80;
-
-        if (defaultPort)
-            return host;
-        else
-            return host + ":" + Integer.toString(port);
-    }
-
-    private String requestURI() {
-        URI uri = request.uri();
-        String method = request.method();
-
-        if ((request.proxy() == null && !method.equals("CONNECT"))
-                || request.isWebSocket()) {
-            return getPathAndQuery(uri);
-        }
-        if (request.secure()) {
-            if (request.method().equals("CONNECT")) {
-                // use authority for connect itself
-                return authorityString(request.authority());
-            } else {
-                // requests over tunnel do not require full URL
-                return getPathAndQuery(uri);
-            }
-        }
-        return uri == null? authorityString(request.authority()) : uri.toString();
-    }
-
-    void sendHeadersOnly() throws IOException {
-        collectHeaders();
-        chan.write(buffers, 0, 2);
-    }
-
-    void sendRequest() throws IOException {
-        collectHeaders();
-        chan.configureMode(Mode.BLOCKING);
-        if (contentLength == 0) {
-            chan.write(buffers, 0, 2);
-        } else if (contentLength > 0) {
-            writeFixedContent(true);
-        } else {
-            writeStreamedContent(true);
-        }
-        setFinished();
-    }
-
-    private boolean finished;
-
-    synchronized boolean finished() {
-        return  finished;
-    }
-
-    synchronized void setFinished() {
-        finished = true;
-    }
-
-    private void collectHeaders() throws IOException {
-        if (Log.requests() && request != null) {
-            Log.logRequest(request.toString());
-        }
-        String uriString = requestURI();
-        StringBuilder sb = new StringBuilder(64);
-        sb.append(request.method())
-          .append(' ')
-          .append(uriString)
-          .append(" HTTP/1.1\r\n");
-        String cmd = sb.toString();
-
-        buffers[0] = ByteBuffer.wrap(cmd.getBytes(StandardCharsets.US_ASCII));
-        URI uri = request.uri();
-        if (uri != null) {
-            systemHeaders.setHeader("Host", hostString());
-        }
-        if (request == null) {
-            // this is not a user request. No content
-            contentLength = 0;
-        } else {
-            contentLength = requestProc.onRequestStart(request, flowController);
-        }
-
-        if (contentLength == 0) {
-            systemHeaders.setHeader("Content-Length", "0");
-            collectHeaders0();
-        } else if (contentLength > 0) {
-            /* [0] request line [1] headers [2] body  */
-            systemHeaders.setHeader("Content-Length",
-                                    Integer.toString((int) contentLength));
-            streaming = false;
-            collectHeaders0();
-            buffers[2] = chan.getBuffer();
-        } else {
-            /* Chunked:
-             *
-             * [0] request line [1] headers [2] chunk header [3] chunk data [4]
-             * final chunk header and trailing CRLF of previous chunks
-             *
-             * 2,3,4 used repeatedly */
-            streaming = true;
-            systemHeaders.setHeader("Transfer-encoding", "chunked");
-            collectHeaders0();
-            buffers[3] = chan.getBuffer();
-        }
-    }
-
-    // The following two methods used by Http1Exchange to handle expect continue
-
-    void continueRequest() throws IOException {
-        if (streaming) {
-            writeStreamedContent(false);
-        } else {
-            writeFixedContent(false);
-        }
-        setFinished();
-    }
-
-    /* Entire request is sent, or just body only  */
-    private void writeStreamedContent(boolean includeHeaders)
-        throws IOException
-    {
-        if (requestProc instanceof HttpRequest.BodyProcessor) {
-            HttpRequest.BodyProcessor pullproc = requestProc;
-            int startbuf, nbufs;
-
-            if (includeHeaders) {
-                startbuf = 0;
-                nbufs = 5;
-            } else {
-                startbuf = 2;
-                nbufs = 3;
-            }
-            try {
-                // TODO: currently each write goes out as one chunk
-                // TODO: should be collecting data and buffer it.
-
-                buffers[3].clear();
-                boolean done = pullproc.onRequestBodyChunk(buffers[3]);
-                int chunklen = buffers[3].position();
-                buffers[2] = getHeader(chunklen);
-                buffers[3].flip();
-                buffers[4] = CRLF_BUFFER();
-                chan.write(buffers, startbuf, nbufs);
-                while (!done) {
-                    buffers[3].clear();
-                    done = pullproc.onRequestBodyChunk(buffers[3]);
-                    if (done)
-                        break;
-                    buffers[3].flip();
-                    chunklen = buffers[3].remaining();
-                    buffers[2] = getHeader(chunklen);
-                    buffers[4] = CRLF_BUFFER();
-                    chan.write(buffers, 2, 3);
-                }
-                buffers[3] = EMPTY_CHUNK_HEADER();
-                buffers[4] = CRLF_BUFFER();
-                chan.write(buffers, 3, 2);
-            } catch (IOException e) {
-                requestProc.onRequestError(e);
-                throw e;
-            }
-        }
-    }
-    /* Entire request is sent, or just body only */
-    private void writeFixedContent(boolean includeHeaders)
-        throws IOException
-    {
-        try {
-            int startbuf, nbufs;
-
-            if (contentLength == 0) {
-                return;
-            }
-            if (includeHeaders) {
-                startbuf = 0;
-                nbufs = 3;
-            } else {
-                startbuf = 2;
-                nbufs = 1;
-                buffers[0].clear().flip();
-                buffers[1].clear().flip();
-            }
-            buffers[2] = chan.getBuffer();
-            if (requestProc instanceof HttpRequest.BodyProcessor) {
-                HttpRequest.BodyProcessor pullproc = requestProc;
-
-                boolean done = pullproc.onRequestBodyChunk(buffers[2]);
-                buffers[2].flip();
-                long headersLength = buffers[0].remaining() + buffers[1].remaining();
-                long contentWritten = buffers[2].remaining();
-                chan.checkWrite(headersLength + contentWritten,
-                                buffers,
-                                startbuf,
-                                nbufs);
-                while (!done) {
-                    buffers[2].clear();
-                    done = pullproc.onRequestBodyChunk(buffers[2]);
-                    buffers[2].flip();
-                    long len = buffers[2].remaining();
-                    if (contentWritten + len > contentLength) {
-                        break;
-                    }
-                    chan.checkWrite(len, buffers[2]);
-                    contentWritten += len;
-                }
-                if (contentWritten != contentLength) {
-                    throw new IOException("wrong content length");
-                }
-            }
-        } catch (IOException e) {
-            requestProc.onRequestError(e);
-            throw e;
-        }
-    }
-
-    private static final byte[] CRLF = {'\r', '\n'};
-    private static final byte[] EMPTY_CHUNK_BYTES = {'0', '\r', '\n'};
-
-    private ByteBuffer CRLF_BUFFER() {
-        return ByteBuffer.wrap(CRLF);
-    }
-
-    private ByteBuffer EMPTY_CHUNK_HEADER() {
-        return ByteBuffer.wrap(EMPTY_CHUNK_BYTES);
-    }
-
-    /* Returns a header for a particular chunk size */
-    private static ByteBuffer getHeader(int size){
-        String hexStr =  Integer.toHexString(size);
-        byte[] hexBytes = hexStr.getBytes(US_ASCII);
-        byte[] header = new byte[hexStr.length()+2];
-        System.arraycopy(hexBytes, 0, header, 0, hexBytes.length);
-        header[hexBytes.length] = CRLF[0];
-        header[hexBytes.length+1] = CRLF[1];
-        return ByteBuffer.wrap(header);
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/Http1Response.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,291 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.function.LongConsumer;
-import static java.net.http.HttpClient.Version.HTTP_1_1;
-
-/**
- * Handles a HTTP/1.1 response in two blocking calls. readHeaders() and
- * readBody(). There can be more than one of these per Http exchange.
- */
-class Http1Response {
-
-    private ResponseContent content;
-    private final HttpRequestImpl request;
-    HttpResponseImpl response;
-    private final HttpConnection connection;
-    private ResponseHeaders headers;
-    private int responseCode;
-    private ByteBuffer buffer; // same buffer used for reading status line and headers
-    private final Http1Exchange exchange;
-    private final boolean redirecting; // redirecting
-    private boolean return2Cache; // return connection to cache when finished
-
-    Http1Response(HttpConnection conn, Http1Exchange exchange) {
-        this.request = exchange.request();
-        this.exchange = exchange;
-        this.connection = conn;
-        this.redirecting = false;
-        buffer = connection.getRemaining();
-    }
-
-    // called when the initial read should come from a buffer left
-    // over from a previous response.
-    void setBuffer(ByteBuffer buffer) {
-        this.buffer = buffer;
-    }
-
-    @SuppressWarnings("unchecked")
-    public void readHeaders() throws IOException {
-        String statusline = readStatusLine();
-        if (statusline == null) {
-            if (Log.errors()) {
-                Log.logError("Connection closed. Retry");
-            }
-            connection.close();
-            // connection was closed
-            throw new IOException("Connection closed");
-        }
-        if (!statusline.startsWith("HTTP/1.")) {
-            throw new IOException("Invalid status line: " + statusline);
-        }
-        char c = statusline.charAt(7);
-        responseCode = Integer.parseInt(statusline.substring(9, 12));
-
-        headers = new ResponseHeaders(connection, buffer);
-        headers.initHeaders();
-        if (Log.headers()) {
-            logHeaders(headers);
-        }
-        response = new HttpResponseImpl(responseCode,
-                                        exchange.exchange,
-                                        headers,
-                                        null,
-                                        connection.sslParameters(),
-                                        HTTP_1_1,
-                                        connection);
-    }
-
-    private boolean finished;
-
-    synchronized void completed() {
-        finished = true;
-    }
-
-    synchronized boolean finished() {
-        return finished;
-    }
-
-    // Blocking flow controller implementation. Only works when a
-    // thread is dedicated to reading response body
-
-    static class FlowController implements LongConsumer {
-        long window ;
-
-        @Override
-        public synchronized void accept(long value) {
-            window += value;
-            notifyAll();
-        }
-
-        public synchronized void request(long value) throws InterruptedException {
-            while (window < value) {
-                wait();
-            }
-            window -= value;
-        }
-    }
-
-    FlowController flowController;
-
-    int fixupContentLen(int clen) {
-        if (request.method().equalsIgnoreCase("HEAD")) {
-            return 0;
-        }
-        if (clen == -1) {
-            if (headers.firstValue("Transfer-encoding").orElse("")
-                       .equalsIgnoreCase("chunked")) {
-                return -1;
-            }
-            return 0;
-        }
-        return clen;
-    }
-
-    private void returnBuffer(ByteBuffer buf) {
-        // not currently used, but will be when we change SSL to use fixed
-        // sized buffers and a single buffer pool for HttpClientImpl
-    }
-
-    @SuppressWarnings("unchecked")
-    public <T> T readBody(java.net.http.HttpResponse.BodyProcessor<T> p,
-                          boolean return2Cache)
-        throws IOException
-    {
-        T body = null; // TODO: check null case below
-        this.return2Cache = return2Cache;
-        final java.net.http.HttpResponse.BodyProcessor<T> pusher = p;
-
-        int clen0 = headers.getContentLength();
-        final int clen = fixupContentLen(clen0);
-
-        flowController = new FlowController();
-
-        body = pusher.onResponseBodyStart(clen, headers, flowController);
-
-        ExecutorWrapper executor;
-        if (body == null) {
-            executor = ExecutorWrapper.callingThread();
-        } else {
-            executor = request.client().executorWrapper();
-        }
-
-        final ResponseHeaders h = headers;
-        if (body == null) {
-            content = new ResponseContent(connection,
-                                          clen,
-                                          h,
-                                          pusher,
-                                          flowController);
-            content.pushBody(headers.getResidue());
-            body = pusher.onResponseComplete();
-            completed();
-            onFinished();
-            return body;
-        } else {
-            executor.execute(() -> {
-                    try {
-                        content = new ResponseContent(connection,
-                                                      clen,
-                                                      h,
-                                                      pusher,
-                                                      flowController);
-                        content.pushBody(headers.getResidue());
-                        pusher.onResponseComplete();
-                        completed();
-                        onFinished();
-                    } catch (Throwable e) {
-                        pusher.onResponseError(e);
-                    }
-                },
-                () -> response.getAccessControlContext());
-        }
-        return body;
-    }
-
-    private void onFinished() {
-        connection.buffer = content.getResidue();
-        if (return2Cache) {
-            connection.returnToCache(headers);
-        }
-    }
-
-    private void logHeaders(ResponseHeaders headers) {
-        Map<String, List<String>> h = headers.mapInternal();
-        Set<String> keys = h.keySet();
-        Set<Map.Entry<String, List<String>>> entries = h.entrySet();
-        for (Map.Entry<String, List<String>> entry : entries) {
-            String key = entry.getKey();
-            StringBuilder sb = new StringBuilder();
-            sb.append(key).append(": ");
-            List<String> values = entry.getValue();
-            if (values != null) {
-                for (String value : values) {
-                    sb.append(value).append(' ');
-                }
-            }
-            Log.logHeaders(sb.toString());
-        }
-    }
-
-    HttpResponseImpl response() {
-        return response;
-    }
-
-    boolean redirecting() {
-        return redirecting;
-    }
-
-    HttpHeaders responseHeaders() {
-        return headers;
-    }
-
-    int responseCode() {
-        return responseCode;
-    }
-
-    static final char CR = '\r';
-    static final char LF = '\n';
-
-    private ByteBuffer getBuffer() throws IOException {
-        if (buffer == null || !buffer.hasRemaining()) {
-            buffer = connection.read();
-        }
-        return buffer;
-    }
-
-    ByteBuffer buffer() {
-        return buffer;
-    }
-
-    String readStatusLine() throws IOException {
-        boolean cr = false;
-        StringBuilder statusLine = new StringBuilder(128);
-        ByteBuffer b;
-        while ((b = getBuffer()) != null) {
-            byte[] buf = b.array();
-            int offset = b.position();
-            int len = b.limit() - offset;
-
-            for (int i = 0; i < len; i++) {
-                char c = (char) buf[i+offset];
-
-                if (cr) {
-                    if (c == LF) {
-                        b.position(i + 1 + offset);
-                        return statusLine.toString();
-                    } else {
-                        throw new IOException("invalid status line");
-                    }
-                }
-                if (c == CR) {
-                    cr = true;
-                } else {
-                    statusLine.append(c);
-                }
-            }
-            // unlikely, but possible, that multiple reads required
-            b.position(b.limit());
-        }
-        return null;
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/Http2ClientImpl.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.URI;
-import static java.net.http.SettingsFrame.INITIAL_WINDOW_SIZE;
-import static java.net.http.SettingsFrame.ENABLE_PUSH;
-import static java.net.http.SettingsFrame.HEADER_TABLE_SIZE;
-import static java.net.http.SettingsFrame.MAX_CONCURRENT_STREAMS;
-import static java.net.http.SettingsFrame.MAX_FRAME_SIZE;
-import java.util.Base64;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- *  Http2 specific aspects of HttpClientImpl
- */
-class Http2ClientImpl {
-
-    final private HttpClientImpl client;
-
-    Http2ClientImpl(HttpClientImpl client) {
-        this.client = client;
-    }
-
-    /* Map key is "scheme:host:port" */
-    final private Map<String,Http2Connection> connections =
-            Collections.synchronizedMap(new HashMap<>());
-
-    final private Set<String> opening = Collections.synchronizedSet(new HashSet<>());
-
-    synchronized boolean haveConnectionFor(URI uri, InetSocketAddress proxy) {
-        return connections.containsKey(Http2Connection.keyFor(uri,proxy));
-    }
-
-    /**
-     * If a https request then blocks and waits until a connection is opened.
-     * Returns null if the request is 'http' as a different (upgrade)
-     * mechanism is used.
-     *
-     * Only one connection per destination is created. Blocks when opening
-     * connection, or when waiting for connection to be opened.
-     * First thread opens the connection and notifies the others when done.
-     *
-     * If the request is secure (https) then we open the connection here.
-     * If not, then the more complicated upgrade from 1.1 to 2 happens (not here)
-     * In latter case, when the Http2Connection is connected, putConnection() must
-     * be called to store it.
-     */
-    Http2Connection getConnectionFor(HttpRequestImpl req)
-            throws IOException, InterruptedException {
-        URI uri = req.uri();
-        InetSocketAddress proxy = req.proxy();
-        String key = Http2Connection.keyFor(uri, proxy);
-        Http2Connection connection;
-        synchronized (opening) {
-            while ((connection = connections.get(key)) == null) {
-                if (!req.secure()) {
-                    return null;
-                }
-                if (!opening.contains(key)) {
-                    opening.add(key);
-                    break;
-                } else {
-                    opening.wait();
-                }
-            }
-        }
-        if (connection != null) {
-            return connection;
-        }
-        // we are opening the connection here blocking until it is done.
-        connection = new Http2Connection(req);
-        synchronized (opening) {
-            connections.put(key, connection);
-            opening.remove(key);
-            opening.notifyAll();
-        }
-        return connection;
-    }
-
-
-    /*
-     * TODO: If there isn't a connection to the same destination, then
-     * store it. If there is already a connection, then close it
-     */
-    synchronized void putConnection(Http2Connection c) {
-        String key = c.key();
-        connections.put(key, c);
-    }
-
-    synchronized void deleteConnection(Http2Connection c) {
-        String key = c.key();
-        connections.remove(key);
-    }
-
-    HttpClientImpl client() {
-        return client;
-    }
-
-    /** Returns the client settings as a base64 (url) encoded string */
-    String getSettingsString() {
-        SettingsFrame sf = getClientSettings();
-        ByteBufferGenerator bg = new ByteBufferGenerator(client);
-        sf.writeOutgoing(bg);
-        byte[] settings = bg.asByteArray(9); // without the header
-        Base64.Encoder encoder = Base64.getUrlEncoder()
-                                       .withoutPadding();
-        return encoder.encodeToString(settings);
-    }
-
-    private static final int K = 1024;
-
-    SettingsFrame getClientSettings() {
-        SettingsFrame frame = new SettingsFrame();
-        frame.setParameter(HEADER_TABLE_SIZE, Utils.getIntegerNetProperty(
-            "java.net.httpclient.hpack.maxheadertablesize", 16 * K));
-        frame.setParameter(ENABLE_PUSH, Utils.getIntegerNetProperty(
-            "java.net.httpclient.enablepush", 1));
-        frame.setParameter(MAX_CONCURRENT_STREAMS, Utils.getIntegerNetProperty(
-            "java.net.httpclient.maxstreams", 16));
-        frame.setParameter(INITIAL_WINDOW_SIZE, Utils.getIntegerNetProperty(
-            "java.net.httpclient.windowsize", 32 * K));
-        frame.setParameter(MAX_FRAME_SIZE, Utils.getIntegerNetProperty(
-            "java.net.httpclient.maxframesize", 16 * K));
-        frame.computeLength();
-        return frame;
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/Http2Connection.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,791 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.URI;
-import java.net.http.HttpConnection.Mode;
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import sun.net.httpclient.hpack.Encoder;
-import sun.net.httpclient.hpack.Decoder;
-import static java.net.http.SettingsFrame.*;
-import static java.net.http.Utils.BUFSIZE;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Formatter;
-import java.util.stream.Collectors;
-import sun.net.httpclient.hpack.DecodingCallback;
-
-/**
- * An Http2Connection. Encapsulates the socket(channel) and any SSLEngine used
- * over it. Contains an HttpConnection which hides the SocketChannel SSL stuff.
- *
- * Http2Connections belong to a Http2ClientImpl, (one of) which belongs
- * to a HttpClientImpl.
- *
- * Creation cases:
- * 1) upgraded HTTP/1.1 plain tcp connection
- * 2) prior knowledge directly created plain tcp connection
- * 3) directly created HTTP/2 SSL connection which uses ALPN.
- *
- * Sending is done by writing directly to underlying HttpConnection object which
- * is operating in async mode. No flow control applies on output at this level
- * and all writes are just executed as puts to an output Q belonging to HttpConnection
- * Flow control is implemented by HTTP/2 protocol itself.
- *
- * Hpack header compression
- * and outgoing stream creation is also done here, because these operations
- * must be synchronized at the socket level. Stream objects send frames simply
- * by placing them on the connection's output Queue. sendFrame() is called
- * from a higher level (Stream) thread.
- *
- * asyncReceive(ByteBuffer) is always called from the selector thread. It assembles
- * incoming Http2Frames, and directs them to the appropriate Stream.incoming()
- * or handles them directly itself. This thread performs hpack decompression
- * and incoming stream creation (Server push). Incoming frames destined for a
- * stream are provided by calling Stream.incoming().
- */
-class Http2Connection implements BufferHandler {
-
-    final Queue<Http2Frame> outputQ;
-    volatile boolean closed;
-
-    //-------------------------------------
-    final HttpConnection connection;
-    HttpClientImpl client;
-    final Http2ClientImpl client2;
-    Map<Integer,Stream> streams;
-    int nextstreamid = 3; // stream 1 is registered separately
-    int nextPushStream = 2;
-    Encoder hpackOut;
-    Decoder hpackIn;
-    SettingsFrame clientSettings, serverSettings;
-    ByteBufferConsumer bbc;
-    final LinkedList<ByteBuffer> freeList;
-    final String key; // for HttpClientImpl.connections map
-    FrameReader reader;
-
-    // Connection level flow control windows
-    int sendWindow = INITIAL_WINDOW_SIZE;
-
-    final static int DEFAULT_FRAME_SIZE = 16 * 1024;
-    private static ByteBuffer[] empty = Utils.EMPTY_BB_ARRAY;
-
-    final ExecutorWrapper executor;
-
-    /**
-     * This is established by the protocol spec and the peer will update it with
-     * WINDOW_UPDATEs, which affects the sendWindow.
-     */
-    final static int INITIAL_WINDOW_SIZE = 64 * 1024 - 1;
-
-    // TODO: need list of control frames from other threads
-    // that need to be sent
-
-    /**
-     * Case 1) Create from upgraded HTTP/1.1 connection.
-     * Is ready to use. Will not be SSL. exchange is the Exchange
-     * that initiated the connection, whose response will be delivered
-     * on a Stream.
-     */
-    Http2Connection(HttpConnection connection, Http2ClientImpl client2,
-            Exchange exchange) throws IOException, InterruptedException {
-        this.outputQ = new Queue<>();
-        String msg = "Connection send window size " + Integer.toString(sendWindow);
-        Log.logTrace(msg);
-
-        //this.initialExchange = exchange;
-        assert !(connection instanceof SSLConnection);
-        this.connection = connection;
-        this.client = client2.client();
-        this.client2 = client2;
-        this.executor = client.executorWrapper();
-        this.freeList = new LinkedList<>();
-        this.key = keyFor(connection);
-        streams = Collections.synchronizedMap(new HashMap<>());
-        initCommon();
-        //sendConnectionPreface();
-        Stream initialStream = createStream(exchange);
-        initialStream.registerStream(1);
-        initialStream.requestSent();
-        sendConnectionPreface();
-        connection.configureMode(Mode.ASYNC);
-        // start reading and writing
-        // start reading
-        AsyncConnection asyncConn = (AsyncConnection)connection;
-        asyncConn.setAsyncCallbacks(this::asyncReceive, this::shutdown);
-        asyncReceive(connection.getRemaining());
-        asyncConn.startReading();
-    }
-
-    // async style but completes immediately
-    static CompletableFuture<Http2Connection> createAsync(HttpConnection connection,
-            Http2ClientImpl client2, Exchange exchange) {
-        CompletableFuture<Http2Connection> cf = new CompletableFuture<>();
-        try {
-            Http2Connection c = new Http2Connection(connection, client2, exchange);
-            cf.complete(c);
-        } catch (IOException | InterruptedException e) {
-            cf.completeExceptionally(e);
-        }
-        return cf;
-    }
-
-    /**
-     * Cases 2) 3)
-     *
-     * request is request to be sent.
-     */
-    Http2Connection(HttpRequestImpl request) throws IOException, InterruptedException {
-        InetSocketAddress proxy = request.proxy();
-        URI uri = request.uri();
-        InetSocketAddress addr = Utils.getAddress(request);
-        String msg = "Connection send window size " + Integer.toString(sendWindow);
-        Log.logTrace(msg);
-        this.key = keyFor(uri, proxy);
-        this.connection = HttpConnection.getConnection(addr, request, this);
-        streams = Collections.synchronizedMap(new HashMap<>());
-        this.client = request.client();
-        this.client2 = client.client2();
-        this.executor = client.executorWrapper();
-        this.freeList = new LinkedList<>();
-        this.outputQ = new Queue<>();
-        nextstreamid = 1;
-        initCommon();
-        connection.connect();
-        connection.configureMode(Mode.ASYNC);
-        // start reading
-        AsyncConnection asyncConn = (AsyncConnection)connection;
-        asyncConn.setAsyncCallbacks(this::asyncReceive, this::shutdown);
-        sendConnectionPreface();
-        asyncConn.startReading();
-    }
-
-    // NEW
-    synchronized void obtainSendWindow(int amount) throws InterruptedException {
-        while (amount > 0) {
-            int n = Math.min(amount, sendWindow);
-            sendWindow -= n;
-            amount -= n;
-            if (amount > 0)
-                wait();
-        }
-    }
-
-    synchronized void updateSendWindow(int amount) {
-        if (sendWindow == 0) {
-            sendWindow += amount;
-            notifyAll();
-        } else
-            sendWindow += amount;
-    }
-
-    synchronized int sendWindow() {
-        return sendWindow;
-    }
-
-    static String keyFor(HttpConnection connection) {
-        boolean isProxy = connection.isProxied();
-        boolean isSecure = connection.isSecure();
-        InetSocketAddress addr = connection.address();
-
-        return keyString(isSecure, isProxy, addr.getHostString(), addr.getPort());
-    }
-
-    static String keyFor(URI uri, InetSocketAddress proxy) {
-        boolean isSecure = uri.getScheme().equalsIgnoreCase("https");
-        boolean isProxy = proxy != null;
-
-        String host;
-        int port;
-
-        if (isProxy) {
-            host = proxy.getHostString();
-            port = proxy.getPort();
-        } else {
-            host = uri.getHost();
-            port = uri.getPort();
-        }
-        return keyString(isSecure, isProxy, host, port);
-    }
-
-    // {C,S}:{H:P}:host:port
-    // C indicates clear text connection "http"
-    // S indicates secure "https"
-    // H indicates host (direct) connection
-    // P indicates proxy
-    // Eg: "S:H:foo.com:80"
-    static String keyString(boolean secure, boolean proxy, String host, int port) {
-        char c1 = secure ? 'S' : 'C';
-        char c2 = proxy ? 'P' : 'H';
-
-        StringBuilder sb = new StringBuilder(128);
-        sb.append(c1).append(':').append(c2).append(':')
-                .append(host).append(':').append(port);
-        return sb.toString();
-    }
-
-    String key() {
-        return this.key;
-    }
-
-    void putConnection() {
-        client2.putConnection(this);
-    }
-
-    private static String toHexdump1(ByteBuffer bb) {
-        bb.mark();
-        StringBuilder sb = new StringBuilder(512);
-        Formatter f = new Formatter(sb);
-
-        while (bb.hasRemaining()) {
-            int i =  Byte.toUnsignedInt(bb.get());
-            f.format("%02x:", i);
-        }
-        sb.deleteCharAt(sb.length()-1);
-        bb.reset();
-        return sb.toString();
-    }
-
-    private static String toHexdump(ByteBuffer bb) {
-        List<String> words = new ArrayList<>();
-        int i = 0;
-        bb.mark();
-        while (bb.hasRemaining()) {
-            if (i % 2 == 0) {
-                words.add("");
-            }
-            byte b = bb.get();
-            String hex = Integer.toHexString(256 + Byte.toUnsignedInt(b)).substring(1);
-            words.set(i / 2, words.get(i / 2) + hex);
-            i++;
-        }
-        bb.reset();
-        return words.stream().collect(Collectors.joining(" "));
-    }
-
-    private void decodeHeaders(HeaderFrame frame, DecodingCallback decoder) {
-        boolean endOfHeaders = frame.getFlag(HeaderFrame.END_HEADERS);
-
-        ByteBuffer[] buffers = frame.getHeaderBlock();
-        for (int i = 0; i < buffers.length; i++) {
-            hpackIn.decode(buffers[i], endOfHeaders && (i == buffers.length - 1), decoder);
-        }
-    }
-
-    int getInitialSendWindowSize() {
-        return serverSettings.getParameter(SettingsFrame.INITIAL_WINDOW_SIZE);
-    }
-
-    void close() {
-        GoAwayFrame f = new GoAwayFrame();
-        f.setDebugData("Requested by user".getBytes());
-        // TODO: set last stream. For now zero ok.
-        sendFrame(f);
-    }
-
-    // BufferHandler methods
-
-    @Override
-    public ByteBuffer getBuffer(int n) {
-        return client.getBuffer(n);
-    }
-
-    @Override
-    public void returnBuffer(ByteBuffer buf) {
-        client.returnBuffer(buf);
-    }
-
-    @Override
-    public void setMinBufferSize(int n) {
-        client.setMinBufferSize(n);
-    }
-
-    private final Object readlock = new Object();
-
-    void asyncReceive(ByteBuffer buffer) {
-        synchronized (readlock) {
-            try {
-                if (reader == null) {
-                    reader = new FrameReader(buffer);
-                } else {
-                    reader.input(buffer);
-                }
-                while (true) {
-                    if (reader.haveFrame()) {
-                        List<ByteBuffer> buffers = reader.frame();
-
-                        ByteBufferConsumer bbc = new ByteBufferConsumer(buffers, this::getBuffer);
-                        processFrame(bbc);
-                        if (bbc.consumed()) {
-                            reader = new FrameReader();
-                            return;
-                        } else {
-                            reader = new FrameReader(reader);
-                        }
-                    } else
-                        return;
-                }
-            } catch (Throwable e) {
-                String msg = Utils.stackTrace(e);
-                Log.logTrace(msg);
-                shutdown(e);
-            }
-        }
-    }
-
-    void shutdown(Throwable t) {
-        Log.logError(t);
-        closed = true;
-        client2.deleteConnection(this);
-        List<Stream> c = new LinkedList<>(streams.values());
-        for (Stream s : c) {
-            s.cancelImpl(t);
-        }
-        connection.close();
-    }
-
-    /**
-     * Handles stream 0 (common) frames that apply to whole connection and passes
-     * other stream specific frames to that Stream object.
-     *
-     * Invokes Stream.incoming() which is expected to process frame without
-     * blocking.
-     */
-    void processFrame(ByteBufferConsumer bbc) throws IOException, InterruptedException {
-        Http2Frame frame = Http2Frame.readIncoming(bbc);
-        Log.logFrames(frame, "IN");
-        int streamid = frame.streamid();
-        if (streamid == 0) {
-            handleCommonFrame(frame);
-        } else {
-            Stream stream = getStream(streamid);
-            if (stream == null) {
-                // should never receive a frame with unknown stream id
-                resetStream(streamid, ResetFrame.PROTOCOL_ERROR);
-            }
-            if (frame instanceof PushPromiseFrame) {
-                PushPromiseFrame pp = (PushPromiseFrame)frame;
-                handlePushPromise(stream, pp);
-            } else if (frame instanceof HeaderFrame) {
-                // decode headers (or continuation)
-                decodeHeaders((HeaderFrame) frame, stream.rspHeadersConsumer());
-                stream.incoming(frame);
-            } else
-                stream.incoming(frame);
-        }
-    }
-
-    private void handlePushPromise(Stream parent, PushPromiseFrame pp)
-            throws IOException, InterruptedException {
-
-        HttpRequestImpl parentReq = parent.request;
-        int promisedStreamid = pp.getPromisedStream();
-        if (promisedStreamid != nextPushStream) {
-            resetStream(promisedStreamid, ResetFrame.PROTOCOL_ERROR);
-            return;
-        } else {
-            nextPushStream += 2;
-        }
-        HeaderDecoder decoder = new HeaderDecoder();
-        decodeHeaders(pp, decoder);
-        HttpHeadersImpl headers = decoder.headers();
-        HttpRequestImpl pushReq = HttpRequestImpl.createPushRequest(parentReq, headers);
-
-        Stream.PushedStream pushStream = createPushStream(parent, pushReq);
-        pushStream.registerStream(promisedStreamid);
-        parent.incoming_pushPromise(pushReq, pushStream);
-    }
-
-    private void handleCommonFrame(Http2Frame frame)
-            throws IOException, InterruptedException {
-
-        switch (frame.type()) {
-          case SettingsFrame.TYPE:
-          { SettingsFrame f = (SettingsFrame)frame;
-            handleSettings(f);}
-            break;
-          case PingFrame.TYPE:
-          { PingFrame f = (PingFrame)frame;
-            handlePing(f);}
-            break;
-          case GoAwayFrame.TYPE:
-          { GoAwayFrame f = (GoAwayFrame)frame;
-            handleGoAway(f);}
-            break;
-          case WindowUpdateFrame.TYPE:
-          { WindowUpdateFrame f = (WindowUpdateFrame)frame;
-            handleWindowUpdate(f);}
-            break;
-          default:
-            protocolError(ErrorFrame.PROTOCOL_ERROR);
-        }
-    }
-
-    void resetStream(int streamid, int code) throws IOException, InterruptedException {
-        Log.logError(
-            "Resetting stream {0,number,integer} with error code {1,number,integer}",
-            streamid, code);
-        ResetFrame frame = new ResetFrame();
-        frame.streamid(streamid);
-        frame.setErrorCode(code);
-        sendFrame(frame);
-        streams.remove(streamid);
-    }
-
-    private void handleWindowUpdate(WindowUpdateFrame f)
-            throws IOException, InterruptedException {
-        updateSendWindow(f.getUpdate());
-    }
-
-    private void protocolError(int errorCode)
-            throws IOException, InterruptedException {
-        GoAwayFrame frame = new GoAwayFrame();
-        frame.setErrorCode(errorCode);
-        sendFrame(frame);
-        String msg = "Error code: " + errorCode;
-        shutdown(new IOException("protocol error"));
-    }
-
-    private void handleSettings(SettingsFrame frame)
-            throws IOException, InterruptedException {
-        if (frame.getFlag(SettingsFrame.ACK)) {
-            // ignore ack frames for now.
-            return;
-        }
-        serverSettings = frame;
-        SettingsFrame ack = getAckFrame(frame.streamid());
-        sendFrame(ack);
-    }
-
-    private void handlePing(PingFrame frame)
-            throws IOException, InterruptedException {
-        frame.setFlag(PingFrame.ACK);
-        sendFrame(frame);
-    }
-
-    private void handleGoAway(GoAwayFrame frame)
-            throws IOException, InterruptedException {
-        //System.err.printf("GoAWAY: %s\n", ErrorFrame.stringForCode(frame.getErrorCode()));
-        shutdown(new IOException("GOAWAY received"));
-    }
-
-    private void initCommon() {
-        clientSettings = client2.getClientSettings();
-
-        // serverSettings will be updated by server
-        serverSettings = SettingsFrame.getDefaultSettings();
-        hpackOut = new Encoder(serverSettings.getParameter(HEADER_TABLE_SIZE));
-        hpackIn = new Decoder(clientSettings.getParameter(HEADER_TABLE_SIZE));
-    }
-
-    /**
-     * Max frame size we are allowed to send
-     */
-    public int getMaxSendFrameSize() {
-        int param = serverSettings.getParameter(MAX_FRAME_SIZE);
-        if (param == -1) {
-            param = DEFAULT_FRAME_SIZE;
-        }
-        return param;
-    }
-
-    /**
-     * Max frame size we will receive
-     */
-    public int getMaxReceiveFrameSize() {
-        return clientSettings.getParameter(MAX_FRAME_SIZE);
-    }
-
-    // Not sure how useful this is.
-    public int getMaxHeadersSize() {
-        return serverSettings.getParameter(MAX_HEADER_LIST_SIZE);
-    }
-
-    private static final String CLIENT_PREFACE = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n";
-
-    private static final byte[] PREFACE_BYTES =
-        CLIENT_PREFACE.getBytes(StandardCharsets.ISO_8859_1);
-
-    /**
-     * Sends Connection preface and Settings frame with current preferred
-     * values
-     */
-    private void sendConnectionPreface() throws IOException {
-        ByteBufferGenerator bg = new ByteBufferGenerator(this);
-        bg.getBuffer(PREFACE_BYTES.length).put(PREFACE_BYTES);
-        ByteBuffer[] ba = bg.getBufferArray();
-        connection.write(ba, 0, ba.length);
-
-        bg = new ByteBufferGenerator(this);
-        SettingsFrame sf = client2.getClientSettings();
-        Log.logFrames(sf, "OUT");
-        sf.writeOutgoing(bg);
-        WindowUpdateFrame wup = new WindowUpdateFrame();
-        wup.streamid(0);
-        // send a Window update for the receive buffer we are using
-        // minus the initial 64 K specified in protocol
-        wup.setUpdate(client2.client().getReceiveBufferSize() - (64 * 1024 - 1));
-        wup.computeLength();
-        wup.writeOutgoing(bg);
-        Log.logFrames(wup, "OUT");
-        ba = bg.getBufferArray();
-        connection.write(ba, 0, ba.length);
-    }
-
-    /**
-     * Returns an existing Stream with given id, or null if doesn't exist
-     */
-    Stream getStream(int streamid) {
-        return streams.get(streamid);
-    }
-
-    /**
-     * Creates Stream with given id.
-     */
-    Stream createStream(Exchange exchange) {
-        Stream stream = new Stream(client, this, exchange);
-        return stream;
-    }
-
-    Stream.PushedStream createPushStream(Stream parent, HttpRequestImpl pushReq) {
-        Stream.PushGroup<?> pg = parent.request.pushGroup();
-        return new Stream.PushedStream(pg, client, this, parent, pushReq);
-    }
-
-    void putStream(Stream stream, int streamid) {
-        streams.put(streamid, stream);
-    }
-
-    void deleteStream(Stream stream) {
-        streams.remove(stream.streamid);
-    }
-
-    static final int MAX_STREAM = Integer.MAX_VALUE - 2;
-
-    // Number of header bytes in a Headers Frame
-    final static int HEADERS_HEADER_SIZE = 15;
-
-    // Number of header bytes in a Continuation frame
-    final static int CONTIN_HEADER_SIZE = 9;
-
-    /**
-     * Encode the headers into a List<ByteBuffer> and then create HEADERS
-     * and CONTINUATION frames from the list and return the List<Http2Frame>.
-     *
-     * @param frame
-     * @return
-     */
-    private LinkedList<Http2Frame> encodeHeaders(OutgoingHeaders frame) {
-        LinkedList<ByteBuffer> buffers = new LinkedList<>();
-        ByteBuffer buf = getBuffer();
-        buffers.add(buf);
-        encodeHeadersImpl(frame.stream.getRequestPseudoHeaders(), buffers);
-        encodeHeadersImpl(frame.getUserHeaders(), buffers);
-        encodeHeadersImpl(frame.getSystemHeaders(), buffers);
-
-        for (ByteBuffer b : buffers) {
-            b.flip();
-        }
-
-        LinkedList<Http2Frame> frames = new LinkedList<>();
-        int maxframesize = getMaxSendFrameSize();
-
-        HeadersFrame oframe = new HeadersFrame();
-        oframe.setFlags(frame.getFlags());
-        oframe.streamid(frame.streamid());
-
-        oframe.setHeaderBlock(getBufferArray(buffers, maxframesize));
-        frames.add(oframe);
-        // Any buffers left?
-        boolean done = buffers.isEmpty();
-        if (done) {
-            oframe.setFlag(HeaderFrame.END_HEADERS);
-        } else {
-            ContinuationFrame cf = null;
-            while (!done) {
-                cf = new ContinuationFrame();
-                cf.streamid(frame.streamid());
-                cf.setHeaderBlock(getBufferArray(buffers, maxframesize));
-                frames.add(cf);
-                done = buffers.isEmpty();
-            }
-            cf.setFlag(HeaderFrame.END_HEADERS);
-        }
-        return frames;
-    }
-
-    // should always return at least one buffer
-    private static ByteBuffer[] getBufferArray(LinkedList<ByteBuffer> list, int maxsize) {
-        assert maxsize >= BUFSIZE;
-        LinkedList<ByteBuffer> newlist = new LinkedList<>();
-        int size = list.size();
-        int nbytes = 0;
-        for (int i=0; i<size; i++) {
-            ByteBuffer buf = list.getFirst();
-            if (nbytes + buf.remaining() <= maxsize) {
-                nbytes += buf.remaining();
-                newlist.add(buf);
-                list.remove();
-            } else {
-                break;
-            }
-        }
-        return newlist.toArray(empty);
-    }
-
-    /**
-     * Encode all the headers from the given HttpHeadersImpl into the given List.
-     */
-    private void encodeHeadersImpl(HttpHeaders hdrs, LinkedList<ByteBuffer> buffers) {
-        ByteBuffer buffer;
-        if (!(buffer = buffers.getLast()).hasRemaining()) {
-            buffer = getBuffer();
-            buffers.add(buffer);
-        }
-        for (Map.Entry<String, List<String>> e : hdrs.map().entrySet()) {
-            String key = e.getKey();
-            String lkey = key.toLowerCase();
-            List<String> values = e.getValue();
-            for (String value : values) {
-                hpackOut.header(lkey, value);
-                boolean encoded = false;
-                do {
-                    encoded = hpackOut.encode(buffer);
-                    if (!encoded) {
-                        buffer = getBuffer();
-                        buffers.add(buffer);
-                    }
-                } while (!encoded);
-            }
-        }
-    }
-
-    public void sendFrames(List<Http2Frame> frames) throws IOException, InterruptedException {
-        for (Http2Frame frame : frames) {
-            sendFrame(frame);
-        }
-    }
-
-    static Throwable getExceptionFrom(CompletableFuture<?> cf) {
-        try {
-            cf.get();
-            return null;
-        } catch (Throwable e) {
-            if (e.getCause() != null)
-                return e.getCause();
-            else
-                return e;
-        }
-    }
-
-
-    void execute(Runnable r) {
-        executor.execute(r, null);
-    }
-
-    private final Object sendlock = new Object();
-
-    /**
-     *
-     */
-    void sendFrame(Http2Frame frame) {
-        synchronized (sendlock) {
-            try {
-                if (frame instanceof OutgoingHeaders) {
-                    OutgoingHeaders oh = (OutgoingHeaders) frame;
-                    Stream stream = oh.getStream();
-                    stream.registerStream(nextstreamid);
-                    oh.streamid(nextstreamid);
-                    nextstreamid += 2;
-                    // set outgoing window here. This allows thread sending
-                    // body to proceed.
-                    stream.updateOutgoingWindow(getInitialSendWindowSize());
-                    LinkedList<Http2Frame> frames = encodeHeaders(oh);
-                    for (Http2Frame f : frames) {
-                        sendOneFrame(f);
-                    }
-                } else {
-                    sendOneFrame(frame);
-                }
-
-            } catch (IOException e) {
-                if (!closed) {
-                    Log.logError(e);
-                    shutdown(e);
-                }
-            }
-        }
-    }
-
-    /**
-     * Send a frame.
-     *
-     * @param frame
-     * @throws IOException
-     */
-    private void sendOneFrame(Http2Frame frame) throws IOException {
-        ByteBufferGenerator bbg = new ByteBufferGenerator(this);
-        frame.computeLength();
-        Log.logFrames(frame, "OUT");
-        frame.writeOutgoing(bbg);
-        ByteBuffer[] currentBufs = bbg.getBufferArray();
-        connection.write(currentBufs, 0, currentBufs.length);
-    }
-
-
-    private SettingsFrame getAckFrame(int streamid) {
-        SettingsFrame frame = new SettingsFrame();
-        frame.setFlag(SettingsFrame.ACK);
-        frame.streamid(streamid);
-        return frame;
-    }
-
-    static class HeaderDecoder implements DecodingCallback {
-        HttpHeadersImpl headers;
-
-        HeaderDecoder() {
-            this.headers = new HttpHeadersImpl();
-        }
-
-        @Override
-        public void onDecoded(CharSequence name, CharSequence value) {
-            headers.addHeader(name.toString(), value.toString());
-        }
-
-        HttpHeadersImpl headers() {
-            return headers;
-        }
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/Http2Frame.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-/**
- * When sending a frame, the length field must be set in sub-class
- * by calling computeLength()
- */
-abstract class Http2Frame {
-
-    int length = -1;
-    int type;
-    int streamid;
-    int flags;
-
-    // called when reading in only
-    void initCommon(int length, int type, int streamid, int flags) {
-        this.length = length;
-        this.type = type;
-        this.streamid = streamid;
-        this.flags = flags;
-    }
-
-    public int length() {
-        return length;
-    }
-
-    public int type() {
-        return type;
-    }
-
-    public int streamid() {
-        return streamid;
-    }
-
-    public void setFlag(int flag) {
-        flags |= flag;
-    }
-
-    public void setFlags(int flags) {
-        this.flags = flags;
-    }
-
-    public int getFlags() {
-        return flags;
-    }
-
-    public boolean getFlag(int flag) {
-        return (flags & flag) != 0;
-    }
-
-    public void clearFlag(int flag) {
-        flags &= 0xffffffff ^ flag;
-    }
-
-    public void streamid(int streamid) {
-        this.streamid = streamid;
-    }
-
-    abstract void readIncomingImpl(ByteBufferConsumer bc) throws IOException;
-
-    /**
-     * assume given array contains at least one complete frame.
-     */
-    static Http2Frame readIncoming(ByteBufferConsumer bc) throws IOException {
-        int x = bc.getInt();
-        int length = x >> 8;
-        int type = x & 0xff;
-        int flags = bc.getByte();
-        int streamid = bc.getInt();
-        Http2Frame f = null;
-        switch (type) {
-          case DataFrame.TYPE:
-            f = new DataFrame();
-            break;
-          case HeadersFrame.TYPE:
-            f = new HeadersFrame();
-            break;
-          case ContinuationFrame.TYPE:
-            f = new ContinuationFrame();
-            break;
-          case ResetFrame.TYPE:
-            f = new ResetFrame();
-            break;
-          case PriorityFrame.TYPE:
-            f = new PriorityFrame();
-            break;
-          case SettingsFrame.TYPE:
-            f = new SettingsFrame();
-            break;
-          case GoAwayFrame.TYPE:
-            f = new GoAwayFrame();
-            break;
-          case PingFrame.TYPE:
-            f = new PingFrame();
-            break;
-          case PushPromiseFrame.TYPE:
-            f = new PushPromiseFrame();
-            break;
-          case WindowUpdateFrame.TYPE:
-            f = new WindowUpdateFrame();
-            break;
-          default:
-            String msg = Integer.toString(type);
-            throw new IOException("unknown frame type " + msg);
-        }
-        f.initCommon(length, type, streamid, flags);
-        f.readIncomingImpl(bc);
-        return f;
-    }
-
-    public String typeAsString() {
-        return asString(this.type);
-    }
-
-    public static String asString(int type) {
-        switch (type) {
-          case DataFrame.TYPE:
-            return "DATA";
-          case HeadersFrame.TYPE:
-            return "HEADERS";
-          case ContinuationFrame.TYPE:
-            return "CONTINUATION";
-          case ResetFrame.TYPE:
-            return "RESET";
-          case PriorityFrame.TYPE:
-            return "PRIORITY";
-          case SettingsFrame.TYPE:
-            return "SETTINGS";
-          case GoAwayFrame.TYPE:
-            return "GOAWAY";
-          case PingFrame.TYPE:
-            return "PING";
-          case PushPromiseFrame.TYPE:
-            return "PUSH_PROMISE";
-          case WindowUpdateFrame.TYPE:
-            return "WINDOW_UPDATE";
-          default:
-            return "UNKNOWN";
-        }
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(typeAsString())
-                .append(": length=")
-                .append(Integer.toString(length))
-                .append(", streamid=")
-                .append(streamid)
-                .append(", flags=");
-
-        int f = flags;
-        int i = 0;
-        if (f == 0) {
-            sb.append("0 ");
-        } else {
-            while (f != 0) {
-                if ((f & 1) == 1) {
-                    sb.append(flagAsString(1 << i))
-                      .append(' ');
-                }
-                f = f >> 1;
-                i++;
-            }
-        }
-        return sb.toString();
-    }
-
-    // Override
-    String flagAsString(int f) {
-        return "unknown";
-    }
-
-    abstract void computeLength();
-
-    void writeOutgoing(ByteBufferGenerator bg) {
-        if (length == -1) {
-            throw new InternalError("Length not set on outgoing frame");
-        }
-        ByteBuffer buf = bg.getBuffer(9);
-        int x = (length << 8) + type;
-        buf.putInt(x);
-        buf.put((byte)flags);
-        buf.putInt(streamid);
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/HttpClient.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,415 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.net.Authenticator;
-import java.net.CookieManager;
-import java.net.InetSocketAddress;
-import java.net.NetPermission;
-import java.net.ProxySelector;
-import java.net.URI;
-import java.util.Optional;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLParameters;
-
-/**
- * A container for configuration information common to multiple {@link
- * HttpRequest}s. All requests are associated with, and created from a {@code
- * HttpClient}.
- *
- * <p> {@code HttpClient}s are immutable and created from a builder returned
- * from {@link HttpClient#create()}. Request builders that are associated with
- * an application created client, are created by calling {@link #request(URI) }.
- * It is also possible to create a request builder directly which is associated
- * with the <i>default</i> {@code HttpClient} by calling {@link
- * HttpRequest#create(URI)}.
- *
- * <p> The HTTP API functions asynchronously (using {@link
- * java.util.concurrent.CompletableFuture}) and also in a simple synchronous
- * mode, where all work may be done on the calling thread. In asynchronous mode,
- * work is done on the threads supplied by the client's {@link
- * java.util.concurrent.ExecutorService}.
- *
- * <p> <a name="defaultclient"></a> The <i>default</i> {@code HttpClient} is
- * used whenever a request is created without specifying a client explicitly
- * (by calling {@link HttpRequest#create(java.net.URI) HttpRequest.create}).
- * There is only one static instance of this {@code HttpClient}. A reference to
- * the default client can be obtained by calling {@link #getDefault() }. If a
- * security manager is set, then a permission is required for this.
- *
- * <p> See {@link HttpRequest} for examples of usage of this API.
- *
- * @since 9
- */
-public abstract class HttpClient {
-
-    HttpClient() {}
-
-    private static HttpClient defaultClient;
-
-    /**
-     * Creates a new {@code HttpClient} builder.
-     *
-     * @return a {@code HttpClient.Builder}
-     */
-    public static Builder  create() {
-        return new HttpClientBuilderImpl();
-    }
-
-    //public abstract void debugPrint();
-
-    /**
-     * Returns the default {@code HttpClient} that is used when a {@link
-     * HttpRequest} is created without specifying a client. If a security
-     * manager is set, then its {@code checkPermission} method is called with a
-     * {@link java.net.NetPermission} specifying the name "getDefaultHttpClient".
-     * If the caller does not possess this permission a {@code SecurityException}
-     * is thrown.
-     *
-     * @implNote Code running under a security manager can avoid the security
-     * manager check by creating a {@code HttpClient} explicitly.
-     *
-     * @return the default {@code HttpClient}
-     * @throws SecurityException if the caller does not have the required
-     *                           permission
-     */
-    public synchronized static HttpClient getDefault() {
-        Utils.checkNetPermission("getDefaultHttpClient");
-        if (defaultClient == null) {
-            Builder b = create();
-            defaultClient = b.executorService(Executors.newCachedThreadPool())
-                             .build();
-        }
-        return defaultClient;
-    }
-
-    /**
-     * Creates a {@code HttpRequest} builder associated with this client.
-     *
-     * @return a new builder
-     */
-    public abstract HttpRequest.Builder request();
-
-    /**
-     * Creates a {@code HttpRequest} builder associated with this client and
-     * using the given request URI.
-     *
-     * @param uri the request URI
-     * @return a new builder
-     */
-    public abstract HttpRequest.Builder request(URI uri);
-
-    /**
-     * A builder of immutable {@link HttpClient}s. {@code HttpClient.Builder}s
-     * are created by calling {@link HttpClient#create()}.
-     *
-     * <p> Each of the setter methods in this class modifies the state of the
-     * builder and returns <i>this</i> (ie. the same instance). The methods are
-     * not synchronized and should not be called from multiple threads without
-     * external synchronization.
-     *
-     * <p> {@link #build() } returns a new {@code HttpClient} each time it is
-     * called.
-     *
-     * @since 9
-     */
-    public abstract static class Builder {
-
-        Builder() {}
-
-        /**
-         * Sets a cookie manager.
-         *
-         * @param manager the CookieManager
-         * @return this builder
-         * @throws NullPointerException if {@code manager} is null
-         */
-        public abstract Builder cookieManager(CookieManager manager);
-
-        /**
-         * Sets an SSLContext. If a security manager is set, then the caller
-         * must have the {@link java.net.NetPermission NetPermission}
-         * ("setSSLContext")
-         *
-         * <p> The effect of not calling this method, is that a default {@link
-         * javax.net.ssl.SSLContext} is used, which is normally adequate for
-         * client applications that do not need to specify protocols, or require
-         * client authentication.
-         *
-         * @param sslContext the SSLContext
-         * @return this builder
-         * @throws NullPointerException if {@code sslContext} is null
-         * @throws SecurityException if a security manager is set and the
-         *                           caller does not have any required permission
-         */
-        public abstract Builder sslContext(SSLContext sslContext);
-
-        /**
-         * Sets an SSLParameters. If this method is not called, then a default
-         * set of parameters are used. The contents of the given object are
-         * copied. Some parameters which are used internally by the HTTP protocol
-         * implementation (such as application protocol list) should not be set
-         * by callers, as they are ignored.
-         *
-         * @param sslParameters the SSLParameters
-         * @return this builder
-         * @throws NullPointerException if {@code sslParameters} is null
-         */
-        public abstract Builder sslParameters(SSLParameters sslParameters);
-
-        /**
-         * Sets the ExecutorService to be used for sending and receiving
-         * asynchronous requests. If this method is not called, a default
-         * executor service is set, which is the one returned from {@link
-         * java.util.concurrent.Executors#newCachedThreadPool()
-         * Executors.newCachedThreadPool}.
-         *
-         * @param s the ExecutorService
-         * @return this builder
-         * @throws NullPointerException if {@code s} is null
-         */
-        public abstract Builder executorService(ExecutorService s);
-
-        /**
-         * Specifies whether requests will automatically follow redirects issued
-         * by the server. This setting can be overridden on each request. The
-         * default value for this setting is {@link Redirect#NEVER NEVER}
-         *
-         * @param policy the redirection policy
-         * @return this builder
-         * @throws NullPointerException if {@code policy} is null
-         */
-        public abstract Builder followRedirects(Redirect policy);
-
-        /**
-         * Requests a specific HTTP protocol version where possible. If not set,
-         * the version defaults to {@link HttpClient.Version#HTTP_1_1}. If
-         * {@link HttpClient.Version#HTTP_2} is set, then each request will
-         * attempt to upgrade to HTTP/2.  If the upgrade succeeds, then the
-         * response to this request will use HTTP/2 and all subsequent requests
-         * and responses to the same
-         * <a href="https://tools.ietf.org/html/rfc6454#section-4">origin server</a>
-         * will use HTTP/2. If the upgrade fails, then the response will be
-         * handled using HTTP/1.1
-         *
-         * <p>This setting can be over-ridden per request.
-         *
-         * @param version the requested HTTP protocol version
-         * @return this builder
-         * @throws NullPointerException if {@code version} is null
-         */
-        public abstract Builder version(HttpClient.Version version);
-
-        /**
-         * Sets the default priority for any HTTP/2 requests sent from this
-         * client. The value provided must be between {@code 1} and {@code 255}.
-         *
-         * @param priority the priority weighting
-         * @return this builder
-         * @throws IllegalArgumentException if the given priority is out of range
-         */
-        public abstract Builder priority(int priority);
-
-        /**
-         * Enables pipelining mode for HTTP/1.1 requests sent through this
-         * client. When pipelining is enabled requests to the same destination
-         * are sent over existing TCP connections that may already have requests
-         * outstanding. This reduces the number of connections, but may have
-         * a performance impact since responses must be delivered in the same
-         * order that they were sent. By default, pipelining is disabled.
-         *
-         * @param enable {@code true} enables pipelining
-         * @return this builder
-         * @throws UnsupportedOperationException if pipelining mode is not
-         *                                       supported by this implementation
-         */
-        public abstract Builder pipelining(boolean enable);
-
-        /**
-         * Sets a {@link java.net.ProxySelector} for this client. If no selector
-         * is set, then no proxies are used. If a {@code null} parameter is
-         * given then the system wide default proxy selector is used.
-         *
-         * @implNote {@link java.net.ProxySelector#of(InetSocketAddress)}
-         * provides a ProxySelector which uses one proxy for all requests.
-         *
-         * @param selector the ProxySelector
-         * @return this builder
-         */
-        public abstract Builder proxy(ProxySelector selector);
-
-        /**
-         * Sets an authenticator to use for HTTP authentication.
-         *
-         * @param a the Authenticator
-         * @return this builder
-         */
-        public abstract Builder authenticator(Authenticator a);
-
-        /**
-         * Returns a {@link HttpClient} built from the current state of this
-         * builder.
-         *
-         * @return this builder
-         */
-        public abstract HttpClient build();
-    }
-
-
-    /**
-     * Returns an {@code Optional} which contains this client's {@link
-     * CookieManager}. If no CookieManager was set in this client's builder,
-     * then the {@code Optional} is empty.
-     *
-     * @return an {@code Optional} containing this client's CookieManager
-     */
-    public abstract Optional<CookieManager> cookieManager();
-
-    /**
-     * Returns the follow-redirects setting for this client. The default value
-     * for this setting is {@link HttpClient.Redirect#NEVER}
-     *
-     * @return this client's follow redirects setting
-     */
-    public abstract Redirect followRedirects();
-
-    /**
-     * Returns an {@code Optional} containing the ProxySelector for this client.
-     * If no proxy is set then the {@code Optional} is empty.
-     *
-     * @return an {@code Optional} containing this client's proxy selector
-     */
-    public abstract Optional<ProxySelector> proxy();
-
-    /**
-     * Returns the SSLContext, if one was set on this client. If a security
-     * manager is set then then caller must then the caller must have the
-     * {@link java.net.NetPermission NetPermission}("getSSLContext") permission.
-     * If no SSLContext was set, then the default context is returned.
-     *
-     * @return this client's SSLContext
-     */
-    public abstract SSLContext sslContext();
-
-    /**
-     * Returns an {@code Optional} containing the {@link SSLParameters} set on
-     * this client. If no {@code SSLParameters} were set in the client's builder,
-     * then the {@code Optional} is empty.
-     *
-     * @return an {@code Optional} containing this client's SSLParameters
-     */
-    public abstract Optional<SSLParameters> sslParameters();
-
-    /**
-     * Returns an {@code Optional} containing the {@link Authenticator} set on
-     * this client. If no {@code Authenticator} was set in the client's builder,
-     * then the {@code Optional} is empty.
-     *
-     * @return an {@code Optional} containing this client's Authenticator
-     */
-    public abstract Optional<Authenticator> authenticator();
-
-    /**
-     * Returns the HTTP protocol version requested for this client. The default
-     * value is {@link HttpClient.Version#HTTP_1_1}
-     *
-     * @return the HTTP protocol version requested
-     */
-    public abstract HttpClient.Version version();
-
-    /**
-     * Returns whether this client supports HTTP/1.1 pipelining.
-     *
-     * @return whether pipelining allowed
-     */
-    public abstract boolean pipelining();
-
-    /**
-     * Returns the {@code ExecutorService} set on this client. If an {@code
-     * ExecutorService} was not set on the client's builder, then a default
-     * object is returned. The default ExecutorService is created independently
-     * for each client.
-     *
-     * @return this client's ExecutorService
-     */
-    public abstract ExecutorService executorService();
-
-    /**
-     * The HTTP protocol version.
-     *
-     * @since 9
-     */
-    public static enum Version {
-
-        /**
-         * HTTP version 1.1
-         */
-        HTTP_1_1,
-
-        /**
-         * HTTP version 2
-         */
-        HTTP_2
-    }
-
-    /**
-     * Defines automatic redirection policy. This is checked whenever a 3XX
-     * response code is received. If redirection does not happen automatically
-     * then the response is returned to the user, where it can be handled
-     * manually.
-     *
-     * <p> {@code Redirect} policy is set via the {@link
-     * HttpClient.Builder#followRedirects(HttpClient.Redirect)} method.
-     *
-     * @since 9
-     */
-    public static enum Redirect {
-
-        /**
-         * Never redirect.
-         */
-        NEVER,
-
-        /**
-         * Always redirect.
-         */
-        ALWAYS,
-
-        /**
-         * Redirect to same protocol only. Redirection may occur from HTTP URLs
-         * to other HTTP URLs, and from HTTPS URLs to other HTTPS URLs.
-         */
-        SAME_PROTOCOL,
-
-        /**
-         * Redirect always except from HTTPS URLs to HTTP URLs.
-         */
-        SECURE
-    }
-
-}
--- a/src/java.httpclient/share/classes/java/net/http/HttpClientBuilderImpl.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.net.Authenticator;
-import java.net.CookieManager;
-import java.net.ProxySelector;
-import java.util.Objects;
-import java.util.concurrent.ExecutorService;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLParameters;
-
-class HttpClientBuilderImpl extends HttpClient.Builder {
-
-    CookieManager cookieManager;
-    HttpClient.Redirect followRedirects;
-    ProxySelector proxy;
-    Authenticator authenticator;
-    HttpClient.Version version = HttpClient.Version.HTTP_1_1;
-    ExecutorService executor;
-    // Security parameters
-    SSLContext sslContext;
-    SSLParameters sslParams;
-    int priority = -1;
-
-    @Override
-    public HttpClientBuilderImpl cookieManager(CookieManager manager) {
-        Objects.requireNonNull(manager);
-        this.cookieManager = manager;
-        return this;
-    }
-
-
-    @Override
-    public HttpClientBuilderImpl sslContext(SSLContext sslContext) {
-        Objects.requireNonNull(sslContext);
-        Utils.checkNetPermission("setSSLContext");
-        this.sslContext = sslContext;
-        return this;
-    }
-
-
-    @Override
-    public HttpClientBuilderImpl sslParameters(SSLParameters sslParameters) {
-        Objects.requireNonNull(sslParameters);
-        this.sslParams = sslParameters;
-        return this;
-    }
-
-
-    @Override
-    public HttpClientBuilderImpl executorService(ExecutorService s) {
-        Objects.requireNonNull(s);
-        this.executor = s;
-        return this;
-    }
-
-
-    @Override
-    public HttpClientBuilderImpl followRedirects(HttpClient.Redirect policy) {
-        Objects.requireNonNull(policy);
-        this.followRedirects = policy;
-        return this;
-    }
-
-
-    @Override
-    public HttpClientBuilderImpl version(HttpClient.Version version) {
-        Objects.requireNonNull(version);
-        this.version = version;
-        return this;
-    }
-
-
-    @Override
-    public HttpClientBuilderImpl priority(int priority) {
-        if (priority < 1 || priority > 255) {
-            throw new IllegalArgumentException("priority must be between 1 and 255");
-        }
-        this.priority = priority;
-        return this;
-    }
-
-
-    @Override
-    public HttpClientBuilderImpl pipelining(boolean enable) {
-        //To change body of generated methods, choose Tools | Templates.
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-
-    @Override
-    public HttpClientBuilderImpl proxy(ProxySelector proxy) {
-        Objects.requireNonNull(proxy);
-        this.proxy = proxy;
-        return this;
-    }
-
-
-    @Override
-    public HttpClientBuilderImpl authenticator(Authenticator a) {
-        Objects.requireNonNull(a);
-        this.authenticator = a;
-        return this;
-    }
-
-    @Override
-    public HttpClient build() {
-        return HttpClientImpl.create(this);
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,591 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLParameters;
-import java.io.IOException;
-import java.net.Authenticator;
-import java.net.CookieManager;
-import java.net.ProxySelector;
-import java.net.URI;
-import java.nio.ByteBuffer;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.SelectableChannel;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.Selector;
-import java.nio.channels.SocketChannel;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-import java.util.stream.Stream;
-
-import static java.net.http.Utils.BUFSIZE;
-
-/**
- * Client implementation. Contains all configuration information and also
- * the selector manager thread which allows async events to be registered
- * and delivered when they occur. See AsyncEvent.
- */
-class HttpClientImpl extends HttpClient implements BufferHandler {
-
-    private static final ThreadFactory defaultFactory =
-            (r -> new Thread(null, r, "HttpClient_worker", 0, true));
-
-    private final CookieManager cookieManager;
-    private final Redirect followRedirects;
-    private final ProxySelector proxySelector;
-    private final Authenticator authenticator;
-    private final Version version;
-    private boolean pipelining = false;
-    private final ConnectionPool connections;
-    private final ExecutorWrapper executor;
-    // Security parameters
-    private final SSLContext sslContext;
-    private final SSLParameters sslParams;
-    private final SelectorManager selmgr;
-    private final FilterFactory filters;
-    private final Http2ClientImpl client2;
-    private final LinkedList<TimeoutEvent> timeouts;
-
-    public static HttpClientImpl create(HttpClientBuilderImpl builder) {
-        HttpClientImpl impl = new HttpClientImpl(builder);
-        impl.start();
-        return impl;
-    }
-
-    private HttpClientImpl(HttpClientBuilderImpl builder) {
-        if (builder.sslContext == null) {
-            try {
-                sslContext = SSLContext.getDefault();
-            } catch (NoSuchAlgorithmException ex) {
-                throw new InternalError(ex);
-            }
-        } else {
-            sslContext = builder.sslContext;
-        }
-        ExecutorService ex = builder.executor;
-        if (ex == null) {
-            ex = Executors.newCachedThreadPool((r) -> {
-                Thread t = defaultFactory.newThread(r);
-                t.setDaemon(true);
-                return t;
-            });
-        } else {
-            ex = builder.executor;
-        }
-        client2 = new Http2ClientImpl(this);
-        executor = ExecutorWrapper.wrap(ex);
-        cookieManager = builder.cookieManager;
-        followRedirects = builder.followRedirects == null ?
-                Redirect.NEVER : builder.followRedirects;
-        this.proxySelector = builder.proxy;
-        authenticator = builder.authenticator;
-        version = builder.version;
-        if (builder.sslParams == null)
-            sslParams = getDefaultParams(sslContext);
-        else
-            sslParams = builder.sslParams;
-        connections = new ConnectionPool();
-        connections.start();
-        timeouts = new LinkedList<>();
-        try {
-            selmgr = new SelectorManager();
-        } catch (IOException e) {
-            // unlikely
-            throw new InternalError(e);
-        }
-        selmgr.setDaemon(true);
-        filters = new FilterFactory();
-        initFilters();
-    }
-
-    private void start() {
-        selmgr.start();
-    }
-
-    private static SSLParameters getDefaultParams(SSLContext ctx) {
-        SSLParameters params = ctx.getSupportedSSLParameters();
-        params.setProtocols(new String[]{"TLSv1.2"});
-        return params;
-    }
-
-    /**
-     * Wait for activity on given exchange (assuming blocking = false).
-     * It's a no-op if blocking = true. In particular, the following occurs
-     * in the SelectorManager thread.
-     *
-     *  1) mark the connection non-blocking
-     *  2) add to selector
-     *  3) If selector fires for this exchange then
-     *  4)   - mark connection as blocking
-     *  5)   - call AsyncEvent.handle()
-     *
-     * If exchange needs to block again, then call registerEvent() again
-     */
-    void registerEvent(AsyncEvent exchange) throws IOException {
-        selmgr.register(exchange);
-    }
-
-    /**
-     * Only used from RawChannel to disconnect the channel from
-     * the selector
-     */
-    void cancelRegistration(SocketChannel s) {
-        selmgr.cancel(s);
-    }
-
-
-    Http2ClientImpl client2() {
-        return client2;
-    }
-
-    /**
-     * We keep one size of buffer on free list. That size may increase
-     * depending on demand. If that happens we dispose of free buffers
-     * that are smaller than new size.
-     */
-    private final LinkedList<ByteBuffer> freelist = new LinkedList<>();
-    int currentSize = BUFSIZE;
-
-    @Override
-    public synchronized ByteBuffer getBuffer(int size) {
-
-        ByteBuffer buf;
-        if (size == -1)
-            size = currentSize;
-
-        if (size > currentSize)
-            currentSize = size;
-
-        while (!freelist.isEmpty()) {
-            buf = freelist.removeFirst();
-            if (buf.capacity() < currentSize)
-                continue;
-            buf.clear();
-            return buf;
-        }
-        return ByteBuffer.allocate(size);
-    }
-
-    @Override
-    public synchronized void returnBuffer(ByteBuffer buffer) {
-        freelist.add(buffer);
-    }
-
-    @Override
-    public synchronized void setMinBufferSize(int n) {
-        currentSize = Math.max(n, currentSize);
-    }
-
-    // Main loop for this client's selector
-    private final class SelectorManager extends Thread {
-
-        private final Selector selector;
-        private volatile boolean closed;
-        private final List<AsyncEvent> readyList;
-        private final List<AsyncEvent> registrations;
-
-        SelectorManager() throws IOException {
-            super(null, null, "SelectorManager", 0, false);
-            readyList = new ArrayList<>();
-            registrations = new ArrayList<>();
-            selector = Selector.open();
-        }
-
-        // This returns immediately. So caller not allowed to send/receive
-        // on connection.
-
-        synchronized void register(AsyncEvent e) throws IOException {
-            registrations.add(e);
-            selector.wakeup();
-        }
-
-        synchronized void cancel(SocketChannel e) {
-            SelectionKey key = e.keyFor(selector);
-            if (key != null)
-                key.cancel();
-            selector.wakeup();
-        }
-
-        void wakeupSelector() {
-            selector.wakeup();
-        }
-
-        synchronized void shutdown() {
-            closed = true;
-            try {
-                selector.close();
-            } catch (IOException ignored) { }
-        }
-
-        @Override
-        public void run() {
-            try {
-                while (!Thread.currentThread().isInterrupted()) {
-                    synchronized (this) {
-                        for (AsyncEvent exchange : registrations) {
-                            SelectableChannel c = exchange.channel();
-                            try {
-                                c.configureBlocking(false);
-                                SelectionKey key = c.keyFor(selector);
-                                SelectorAttachment sa;
-                                if (key == null) {
-                                    sa = new SelectorAttachment(c, selector);
-                                } else {
-                                    sa = (SelectorAttachment) key.attachment();
-                                }
-                                sa.register(exchange);
-                            } catch (IOException e) {
-                                Log.logError("HttpClientImpl: " + e);
-                                c.close();
-                                // let the exchange deal with it
-                                handleEvent(exchange);
-                            }
-                        }
-                        registrations.clear();
-                    }
-                    long timeval = getTimeoutValue();
-                    long now = System.currentTimeMillis();
-                    //debugPrint(selector);
-                    int n = selector.select(timeval);
-                    if (n == 0) {
-                        signalTimeouts(now);
-                        continue;
-                    }
-                    Set<SelectionKey> keys = selector.selectedKeys();
-
-                    for (SelectionKey key : keys) {
-                        SelectorAttachment sa = (SelectorAttachment) key.attachment();
-                        int eventsOccurred = key.readyOps();
-                        sa.events(eventsOccurred).forEach(readyList::add);
-                        sa.resetInterestOps(eventsOccurred);
-                    }
-                    selector.selectNow(); // complete cancellation
-                    selector.selectedKeys().clear();
-
-                    for (AsyncEvent exchange : readyList) {
-                        if (exchange.blocking()) {
-                            exchange.channel().configureBlocking(true);
-                        }
-                        executor.synchronize();
-                        handleEvent(exchange); // will be delegated to executor
-                    }
-                    readyList.clear();
-                }
-            } catch (Throwable e) {
-                if (!closed) {
-                    // This terminates thread. So, better just print stack trace
-                    String err = Utils.stackTrace(e);
-                    Log.logError("HttpClientImpl: fatal error: " + err);
-                }
-            } finally {
-                shutdown();
-            }
-        }
-
-        void debugPrint(Selector selector) {
-            System.err.println("Selector: debugprint start");
-            Set<SelectionKey> keys = selector.keys();
-            for (SelectionKey key : keys) {
-                SelectableChannel c = key.channel();
-                int ops = key.interestOps();
-                System.err.printf("selector chan:%s ops:%d\n", c, ops);
-            }
-            System.err.println("Selector: debugprint end");
-        }
-
-        void handleEvent(AsyncEvent e) {
-            if (closed) {
-                e.abort();
-            } else {
-                e.handle();
-            }
-        }
-    }
-
-    /**
-     * Tracks multiple user level registrations associated with one NIO
-     * registration (SelectionKey). In this implementation, registrations
-     * are one-off and when an event is posted the registration is cancelled
-     * until explicitly registered again.
-     *
-     * <p> No external synchronization required as this class is only used
-     * by the SelectorManager thread. One of these objects required per
-     * connection.
-     */
-    private static class SelectorAttachment {
-        private final SelectableChannel chan;
-        private final Selector selector;
-        private final ArrayList<AsyncEvent> pending;
-        private int interestOps;
-
-        SelectorAttachment(SelectableChannel chan, Selector selector) {
-            this.pending = new ArrayList<>();
-            this.chan = chan;
-            this.selector = selector;
-        }
-
-        void register(AsyncEvent e) throws ClosedChannelException {
-            int newOps = e.interestOps();
-            boolean reRegister = (interestOps & newOps) != newOps;
-            interestOps |= newOps;
-            pending.add(e);
-            if (reRegister) {
-                // first time registration happens here also
-                chan.register(selector, interestOps, this);
-            }
-        }
-
-        /**
-         * Returns a Stream<AsyncEvents> containing only events that are
-         * registered with the given {@code interestOps}.
-         */
-        Stream<AsyncEvent> events(int interestOps) {
-            return pending.stream()
-                    .filter(ev -> (ev.interestOps() & interestOps) != 0);
-        }
-
-        /**
-         * Removes any events with the given {@code interestOps}, and if no
-         * events remaining, cancels the associated SelectionKey.
-         */
-        void resetInterestOps(int interestOps) {
-            int newOps = 0;
-
-            Iterator<AsyncEvent> itr = pending.iterator();
-            while (itr.hasNext()) {
-                AsyncEvent event = itr.next();
-                int evops = event.interestOps();
-                if (event.repeating()) {
-                    newOps |= evops;
-                    continue;
-                }
-                if ((evops & interestOps) != 0) {
-                    itr.remove();
-                } else {
-                    newOps |= evops;
-                }
-            }
-
-            this.interestOps = newOps;
-            SelectionKey key = chan.keyFor(selector);
-            if (newOps == 0) {
-                key.cancel();
-            } else {
-                key.interestOps(newOps);
-            }
-        }
-    }
-
-    /**
-     * Creates a HttpRequest associated with this group.
-     *
-     * @throws IllegalStateException
-     *         if the group has been stopped
-     */
-    @Override
-    public HttpRequestBuilderImpl request() {
-        return new HttpRequestBuilderImpl(this, null);
-    }
-
-    /**
-     * Creates a HttpRequest associated with this group.
-     *
-     * @throws IllegalStateException
-     *         if the group has been stopped
-     */
-    @Override
-    public HttpRequestBuilderImpl request(URI uri) {
-        return new HttpRequestBuilderImpl(this, uri);
-    }
-
-    @Override
-    public SSLContext sslContext() {
-        Utils.checkNetPermission("getSSLContext");
-        return sslContext;
-    }
-
-    @Override
-    public Optional<SSLParameters> sslParameters() {
-        return Optional.ofNullable(sslParams);
-    }
-
-    @Override
-    public Optional<Authenticator> authenticator() {
-        return Optional.ofNullable(authenticator);
-    }
-
-    @Override
-    public ExecutorService executorService() {
-        return executor.userExecutor();
-    }
-
-    ExecutorWrapper executorWrapper() {
-        return executor;
-    }
-
-    @Override
-    public boolean pipelining() {
-        return this.pipelining;
-    }
-
-    ConnectionPool connectionPool() {
-        return connections;
-    }
-
-    @Override
-    public Redirect followRedirects() {
-        return followRedirects;
-    }
-
-
-    @Override
-    public Optional<CookieManager> cookieManager() {
-        return Optional.ofNullable(cookieManager);
-    }
-
-    @Override
-    public Optional<ProxySelector> proxy() {
-        return Optional.ofNullable(this.proxySelector);
-    }
-
-    @Override
-    public Version version() {
-        return version;
-    }
-
-    //private final HashMap<String, Boolean> http2NotSupported = new HashMap<>();
-
-    boolean getHttp2Allowed() {
-        return version.equals(Version.HTTP_2);
-    }
-
-    private void initFilters() {
-        addFilter(AuthenticationFilter.class);
-        addFilter(RedirectFilter.class);
-    }
-
-    private void addFilter(Class<? extends HeaderFilter> f) {
-        filters.addFilter(f);
-    }
-
-    final List<HeaderFilter> filterChain() {
-        return filters.getFilterChain();
-    }
-
-    // Timer controls. Timers are implemented through timed Selector.select()
-    // calls.
-    synchronized void registerTimer(TimeoutEvent event) {
-        long elapse = event.timevalMillis();
-        ListIterator<TimeoutEvent> iter = timeouts.listIterator();
-        long listval = 0;
-        event.delta = event.timeval; // in case list empty
-        TimeoutEvent next;
-        while (iter.hasNext()) {
-            next = iter.next();
-            listval += next.delta;
-            if (elapse < listval) {
-                listval -= next.delta;
-                event.delta = elapse - listval;
-                next.delta -= event.delta;
-                iter.previous();
-                break;
-            } else if (!iter.hasNext()) {
-                event.delta = event.timeval - listval;
-            }
-        }
-        iter.add(event);
-        selmgr.wakeupSelector();
-    }
-
-    private synchronized void signalTimeouts(long then) {
-        if (timeouts.isEmpty()) {
-            return;
-        }
-        long now = System.currentTimeMillis();
-        long duration = now - then;
-        ListIterator<TimeoutEvent> iter = timeouts.listIterator();
-        TimeoutEvent event = iter.next();
-        long delta = event.delta;
-        if (duration < delta) {
-            event.delta -= duration;
-            return;
-        }
-        event.handle();
-        iter.remove();
-        while (iter.hasNext()) {
-            event = iter.next();
-            if (event.delta == 0) {
-                event.handle();
-                iter.remove();
-            } else {
-                event.delta += delta;
-                break;
-            }
-        }
-    }
-
-    synchronized void cancelTimer(TimeoutEvent event) {
-        ListIterator<TimeoutEvent> iter = timeouts.listIterator();
-        while (iter.hasNext()) {
-            TimeoutEvent ev = iter.next();
-            if (event == ev) {
-                if (iter.hasNext()) {
-                    // adjust
-                    TimeoutEvent next = iter.next();
-                    next.delta += ev.delta;
-                    iter.previous();
-                }
-                iter.remove();
-            }
-        }
-    }
-
-    // used for the connection window
-    int getReceiveBufferSize() {
-        return Utils.getIntegerNetProperty(
-                "java.net.httpclient.connectionWindowSize", 256 * 1024
-        );
-    }
-
-    // returns 0 meaning block forever, or a number of millis to block for
-    private synchronized long getTimeoutValue() {
-        if (timeouts.isEmpty()) {
-            return 0;
-        } else {
-            return timeouts.get(0).delta;
-        }
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/HttpConnection.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,353 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.channels.SocketChannel;
-import java.util.concurrent.CompletableFuture;
-import javax.net.ssl.SSLParameters;
-
-/**
- * Wraps socket channel layer and takes care of SSL also.
- *
- * Subtypes are:
- *      PlainHttpConnection: regular direct TCP connection to server
- *      PlainProxyConnection: plain text proxy connection
- *      PlainTunnelingConnection: opens plain text (CONNECT) tunnel to server
- *      SSLConnection: TLS channel direct to server
- *      SSLTunnelConnection: TLS channel via (CONNECT) proxy tunnel
- */
-abstract class HttpConnection implements BufferHandler, Closeable {
-
-    protected final static ByteBuffer emptyBuf = Utils.EMPTY_BYTEBUFFER;
-
-    enum Mode {
-        BLOCKING,
-        NON_BLOCKING,
-        ASYNC
-    }
-
-    protected Mode mode;
-
-    // address we are connected to. Could be a server or a proxy
-    final InetSocketAddress address;
-    final HttpClientImpl client;
-    protected volatile ByteBuffer buffer;
-
-    HttpConnection(InetSocketAddress address, HttpClientImpl client) {
-        this.address = address;
-        this.client = client;
-        this.buffer = emptyBuf;
-    }
-
-    /**
-     * Public API to this class. addr is the ultimate destination. Any proxies
-     * etc are figured out from the request. Returns an instance of one of the
-     * following
-     *      PlainHttpConnection
-     *      PlainTunnelingConnection
-     *      SSLConnection
-     *      SSLTunnelConnection
-     *
-     * When object returned, connect() or connectAsync() must be called, which
-     * when it returns/completes, the connection is usable for requests.
-     */
-    public static HttpConnection getConnection(InetSocketAddress addr,
-                                               HttpRequestImpl request) {
-        return getConnectionImpl(addr, request, null);
-    }
-
-    /**
-     * Called specifically to get an async connection for HTTP/2 over SSL.
-     *
-     * @param addr
-     * @param request
-     * @param http2
-     * @return
-     */
-    public static HttpConnection getConnection(InetSocketAddress addr,
-        HttpRequestImpl request, Http2Connection http2) {
-
-        return getConnectionImpl(addr, request, http2);
-    }
-
-    public abstract void connect() throws IOException, InterruptedException;
-
-    public abstract CompletableFuture<Void> connectAsync();
-
-    /**
-     * Returns whether this connection is connected to its destination
-     */
-    abstract boolean connected();
-
-    abstract boolean isSecure();
-
-    abstract boolean isProxied();
-
-    /**
-     * Completes when the first byte of the response is available to be read.
-     */
-    abstract CompletableFuture<Void> whenReceivingResponse();
-
-    // must be called before reading any data off connection
-    // at beginning of response.
-    ByteBuffer getRemaining() {
-        ByteBuffer b = buffer;
-        buffer = emptyBuf;
-        return b;
-    }
-
-    final boolean isOpen() {
-        return channel().isOpen();
-    }
-
-    /* Returns either a plain HTTP connection or a plain tunnelling connection
-     * for proxied websockets */
-    private static HttpConnection getPlainConnection(InetSocketAddress addr,
-                                                     InetSocketAddress proxy,
-                                                     HttpRequestImpl request) {
-        HttpClientImpl client = request.client();
-
-        if (request.isWebSocket() && proxy != null) {
-            return new PlainTunnelingConnection(addr,
-                                                proxy,
-                                                client,
-                                                request.getAccessControlContext());
-        } else {
-            if (proxy == null) {
-                return new PlainHttpConnection(addr, client);
-            } else {
-                return new PlainProxyConnection(proxy, client);
-            }
-        }
-    }
-
-    private static HttpConnection getSSLConnection(InetSocketAddress addr,
-            InetSocketAddress proxy, HttpRequestImpl request,
-            String[] alpn, Http2Connection http2) {
-        HttpClientImpl client = request.client();
-        if (proxy != null) {
-            return new SSLTunnelConnection(addr,
-                                           client,
-                                           proxy,
-                                           request.getAccessControlContext());
-        } else if (http2 == null) {
-            return new SSLConnection(addr, client, alpn);
-        } else {
-            return new AsyncSSLConnection(addr, client, alpn);
-        }
-    }
-
-    /**
-     * Main factory method.   Gets a HttpConnection, either cached or new if
-     * none available.
-     */
-    private static HttpConnection getConnectionImpl(InetSocketAddress addr,
-            HttpRequestImpl request, Http2Connection http2) {
-
-        HttpConnection c;
-        HttpClientImpl client = request.client();
-        InetSocketAddress proxy = request.proxy();
-        boolean secure = request.secure();
-        ConnectionPool pool = client.connectionPool();
-        String[] alpn =  null;
-
-        if (secure && request.requestHttp2()) {
-            alpn = new String[1];
-            alpn[0] = "h2";
-        }
-
-        if (!secure) {
-            c = pool.getConnection(false, addr, proxy);
-            if (c != null) {
-                return c;
-            } else {
-                return getPlainConnection(addr, proxy, request);
-            }
-        } else {
-            c = pool.getConnection(true, addr, proxy);
-            if (c != null) {
-                return c;
-            } else {
-                return getSSLConnection(addr, proxy, request, alpn, http2);
-            }
-        }
-    }
-
-    void returnToCache(HttpHeaders hdrs) {
-        if (hdrs == null) {
-            // the connection was closed by server
-            close();
-            return;
-        }
-        if (!isOpen()) {
-            return;
-        }
-        ConnectionPool pool = client.connectionPool();
-        boolean keepAlive = hdrs.firstValue("Connection")
-                .map((s) -> !s.equalsIgnoreCase("close"))
-                .orElse(true);
-
-        if (keepAlive) {
-            pool.returnToPool(this);
-        } else {
-            close();
-        }
-    }
-
-    /**
-     * Also check that the number of bytes written is what was expected. This
-     * could be different if the buffer is user-supplied and its internal
-     * pointers were manipulated in a race condition.
-     */
-    final void checkWrite(long expected, ByteBuffer buffer) throws IOException {
-        long written = write(buffer);
-        if (written != expected) {
-            throw new IOException("incorrect number of bytes written");
-        }
-    }
-
-    final void checkWrite(long expected,
-                          ByteBuffer[] buffers,
-                          int start,
-                          int length)
-        throws IOException
-    {
-        long written = write(buffers, start, length);
-        if (written != expected) {
-            throw new IOException("incorrect number of bytes written");
-        }
-    }
-
-    abstract SocketChannel channel();
-
-    final InetSocketAddress address() {
-        return address;
-    }
-
-    synchronized void configureMode(Mode mode) throws IOException {
-        this.mode = mode;
-        if (mode == Mode.BLOCKING)
-            channel().configureBlocking(true);
-        else
-            channel().configureBlocking(false);
-    }
-
-    abstract ConnectionPool.CacheKey cacheKey();
-
-    // overridden in SSL only
-    SSLParameters sslParameters() {
-        return null;
-    }
-
-    // Methods to be implemented for Plain TCP and SSL
-
-    abstract long write(ByteBuffer[] buffers, int start, int number)
-        throws IOException;
-
-    abstract long write(ByteBuffer buffer) throws IOException;
-
-    /**
-     * Closes this connection, by returning the socket to its connection pool.
-     */
-    @Override
-    public abstract void close();
-
-    /**
-     * Returns a ByteBuffer with data, or null if EOF.
-     */
-    final ByteBuffer read() throws IOException {
-        return read(-1);
-    }
-
-    /**
-     * Puts position to limit and limit to capacity so we can resume reading
-     * into this buffer, but if required > 0 then limit may be reduced so that
-     * no more than required bytes are read next time.
-     */
-    static void resumeChannelRead(ByteBuffer buf, int required) {
-        int limit = buf.limit();
-        buf.position(limit);
-        int capacity = buf.capacity() - limit;
-        if (required > 0 && required < capacity) {
-            buf.limit(limit + required);
-        } else {
-            buf.limit(buf.capacity());
-        }
-    }
-
-    /**
-     * Blocks ands return requested amount.
-     */
-    final ByteBuffer read(int length) throws IOException {
-        if (length <= 0) {
-            buffer = readImpl(length);
-            return buffer;
-        }
-        buffer = readImpl(length);
-        int required = length - buffer.remaining();
-        while (buffer.remaining() < length) {
-            resumeChannelRead(buffer, required);
-            int n = readImpl(buffer);
-            required -= n;
-        }
-        return buffer;
-    }
-
-    final int read(ByteBuffer buffer) throws IOException {
-        int n = readImpl(buffer);
-        return n;
-    }
-
-    /** Reads up to length bytes. */
-    protected abstract ByteBuffer readImpl(int length) throws IOException;
-
-    /** Reads as much as possible into given buffer and returns amount read. */
-    protected abstract int readImpl(ByteBuffer buffer) throws IOException;
-
-    @Override
-    public String toString() {
-        return "HttpConnection: " + channel().toString();
-    }
-
-    @Override
-    public final ByteBuffer getBuffer(int n) {
-        return client.getBuffer(n);
-    }
-
-    @Override
-    public final void returnBuffer(ByteBuffer buffer) {
-        client.returnBuffer(buffer);
-    }
-
-    @Override
-    public final void setMinBufferSize(int n) {
-        client.setMinBufferSize(n);
-    }
-}
--- a/src/java.httpclient/share/classes/java/net/http/HttpHeaders.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * A read-only view of a set of received HTTP headers.
- *
- * @since 9
- */
-public interface HttpHeaders {
-
-    /**
-     * Returns an {@link java.util.Optional} containing the first value of the
-     * given named (and possibly multi-valued) header. If the header is not
-     * present, then the returned {@code Optional} is empty.
-     *
-     * @param name the header name
-     * @return an {@code Optional<String>} for the first named value
-     */
-    public Optional<String> firstValue(String name);
-
-    /**
-     * Returns an {@link java.util.Optional} containing the first value of the
-     * named header field as an {@literal Optional<Long>}. If the header is not
-     * present, then the Optional is empty. If the header is present but
-     * contains a value that does not parse as a {@code Long} value, then an
-     * exception is thrown.
-     *
-     * @param name the header name
-     * @return  an {@code Optional<Long>}
-     * @throws NumberFormatException if a value is found, but does not parse as
-     *                               a Long
-     */
-    public Optional<Long> firstValueAsLong(String name);
-
-    /**
-     * Returns an unmodifiable List of all of the values of the given named
-     * header. Always returns a List, which may be empty if the header is not
-     * present.
-     *
-     * @param name the header name
-     * @return a List of String values
-     */
-    public List<String> allValues(String name);
-
-    /**
-     * Returns an unmodifiable multi Map view of this HttpHeaders. This
-     * interface should only be used when it is required to iterate over the
-     * entire set of headers.
-     *
-     * @return the Map
-     */
-    public Map<String,List<String>> map();
-}
--- a/src/java.httpclient/share/classes/java/net/http/HttpHeadersImpl.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.TreeMap;
-
-/**
- * Implementation of HttpHeaders.
- */
-class HttpHeadersImpl implements HttpHeaders {
-
-    private final TreeMap<String,List<String>> headers;
-
-    public HttpHeadersImpl() {
-        headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
-    }
-
-    @Override
-    public Optional<String> firstValue(String name) {
-        List<String> l = headers.get(name);
-        return Optional.ofNullable(l == null ? null : l.get(0));
-    }
-
-    @Override
-    public List<String> allValues(String name) {
-        return headers.get(name);
-    }
-
-    @Override
-    public Map<String, List<String>> map() {
-        return Collections.unmodifiableMap(headers);
-    }
-
-    Map<String, List<String>> directMap() {
-        return headers;
-    }
-
-    // package private mutators
-
-    public HttpHeadersImpl deepCopy() {
-        HttpHeadersImpl h1 = new HttpHeadersImpl();
-        TreeMap<String,List<String>> headers1 = h1.headers;
-        Set<String> keys = headers.keySet();
-        for (String key : keys) {
-            List<String> vals = headers.get(key);
-            LinkedList<String> vals1 = new LinkedList<>(vals);
-            headers1.put(key, vals1);
-        }
-        return h1;
-    }
-
-    void addHeader(String name, String value) {
-        headers.computeIfAbsent(name, k -> new LinkedList<>())
-               .add(value);
-    }
-
-    void setHeader(String name, String value) {
-        List<String> l = headers.computeIfAbsent(name, k -> new LinkedList<>());
-        l.clear();
-        l.add(value);
-    }
-
-    @Override
-    public Optional<Long> firstValueAsLong(String name) {
-        List<String> l = headers.get(name);
-        if (l == null) {
-            return Optional.empty();
-        } else {
-            String v = l.get(0);
-            Long lv = Long.parseLong(v);
-            return Optional.of(lv);
-        }
-    }
-
-    void clear() {
-        headers.clear();
-    }
-}
\ No newline at end of file
--- a/src/java.httpclient/share/classes/java/net/http/HttpRedirectImpl.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.net.*;
-
-interface HttpRedirectImpl {
-
-    static HttpRedirectImpl getRedirects(java.net.http.HttpClient.Redirect redir) {
-        switch (redir) {
-            case NEVER:
-                return HttpRedirectImpl.NEVER;
-            case ALWAYS:
-                return HttpRedirectImpl.ALWAYS;
-            case SECURE:
-                return HttpRedirectImpl.SECURE;
-            case SAME_PROTOCOL:
-                return HttpRedirectImpl.SAME_PROTOCOL;
-        }
-        return HttpRedirectImpl.NEVER;
-    }
-
-    static HttpClient.Redirect getRedirects(HttpRedirectImpl redir) {
-        if (redir == HttpRedirectImpl.NEVER) {
-            return HttpClient.Redirect.NEVER;
-        } else if (redir == HttpRedirectImpl.ALWAYS) {
-            return HttpClient.Redirect.ALWAYS;
-        } else if (redir == HttpRedirectImpl.SECURE) {
-            return HttpClient.Redirect.SECURE;
-        } else {
-            return HttpClient.Redirect.SAME_PROTOCOL;
-        }
-    }
-
-    /**
-     * Called to determine whether the given intermediate response
-     * with a redirection response code should be redirected. The target URI
-     * can be obtained from the "Location" header in the given response object.
-     *
-     * @param rsp the response from the redirected resource
-     * @return {@code true} if the redirect should be attempted automatically
-     * or {@code false} if not.
-     */
-    boolean redirect(HttpResponse rsp);
-
-    /**
-     * Never redirect.
-     */
-    static HttpRedirectImpl NEVER = (HttpResponse rsp) -> false;
-
-    /**
-     * Always redirect.
-     */
-    static HttpRedirectImpl ALWAYS = (HttpResponse rsp) -> true;
-
-    /**
-     * Redirect to same protocol only. Redirection may occur from HTTP URLs to
-     * other THHP URLs and from HTTPS URLs to other HTTPS URLs.
-     */
-    static HttpRedirectImpl SAME_PROTOCOL = (HttpResponse rsp) -> {
-        String orig = rsp.request().uri().getScheme().toLowerCase();
-        String redirect = URI.create(
-                rsp.headers().firstValue("Location").orElse(""))
-                .getScheme().toLowerCase();
-        return orig.equals(redirect);
-    };
-
-    /**
-     * Redirect always except from HTTPS URLs to HTTP URLs.
-     */
-    static HttpRedirectImpl SECURE = (HttpResponse rsp) -> {
-        String orig = rsp.request().uri().getScheme().toLowerCase();
-        String redirect = URI.create(
-                rsp.headers().firstValue("Location").orElse(""))
-                .getScheme().toLowerCase();
-        if (orig.equals("https")) {
-            return redirect.equals("https");
-        }
-        return true;
-    };
-}
--- a/src/java.httpclient/share/classes/java/net/http/HttpRequest.java	Fri Dec 09 17:01:03 2016 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,871 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.net.http;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UncheckedIOException;
-import java.net.URI;
-import java.net.ProxySelector;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.charset.*;
-import java.nio.file.Path;
-import java.util.Iterator;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.function.LongConsumer;
-
-/**
- * Represents one HTTP request which can be sent to a server. {@code
- * HttpRequest}s are built from {@code HttpRequest} {@link HttpRequest.Builder
- * builder}s. {@code HttpRequest} builders are obtained from a {@link HttpClient}
- * by calling {@link HttpClient#request(java.net.URI) HttpClient.request}, or
- * by calling {@link #create(java.net.URI) HttpRequest.create} which returns a
- * builder on the <a href="HttpClient.html#defaultclient">default</a> client.
- * A request's {@link java.net.URI}, headers and body can be set. Request bodies
- * are provided through a {@link BodyProcessor} object. Once all required
- * parameters have been set in the builder, one of the builder methods should be
- * called, which sets the request method and returns a {@code HttpRequest}.
- * These methods are {@link Builder#GET() GET}, {@link HttpRequest.Builder#POST()
- * POST} and {@link HttpRequest.Builder#PUT() PUT} which return a GET, POST or
- * PUT request respectively. Alternatively, {@link
- * HttpRequest.Builder#method(String) method} can be called to set an arbitrary
- * method type (and return a {@code HttpRequest}). Builders can also be copied
- * and modified multiple times in order to build multiple related requests that
- * differ in some parameters.
- *
- * <p> Two simple, example HTTP interactions are shown below:
- * <pre>
- * {@code
- *      // GET
- *      HttpResponse response = HttpRequest
- *          .create(new URI("http://www.foo.com"))
- *          .headers("Foo", "foovalue", "Bar", "barvalue")
- *          .GET()
- *          .response();
- *
- *      int statusCode = response.statusCode();
- *      String responseBody = response.body(asString());
- *
- *      // POST
- *      response = HttpRequest
- *          .create(new URI("http://www.foo.com"))
- *          .body(fromString("param1=foo,param2=bar"))
- *          .POST()
- *          .response();}
- * </pre>
- *
- * <p> The request is sent and the response obtained by calling one of the
- * following methods.
- * <ul><li>{@link #response() response} blocks until the entire request has been
- * sent and the response status code and headers have been received.</li>
- * <li>{@link #responseAsync() responseAsync} sends the request and receives the
- * response asynchronously. Returns immediately with a
- * {@link java.util.concurrent.CompletableFuture CompletableFuture}&lt;{@link
- * HttpResponse}&gt;.</li>
- * <li>{@link #multiResponseAsync(HttpResponse.MultiProcessor) multiResponseAsync}
- * sends the request asynchronously, expecting multiple responses. This
- * capability is of most relevance to HTTP/2 server push, but can be used for
- * single responses (HTTP/1.1 or HTTP/2) also.</li>
- * </ul>
- *
- * <p> Once a request has been sent, it is an error to try and send it again.
- *
- * <p> Once a {@code HttpResponse} is received, the headers and response code are
- * available. The body can then be received by calling one of the body methods
- * on {@code HttpResponse}.
- *
- * <p> See below for discussion of synchronous versus asynchronous usage.
- *
- * <p> <b>Request bodies</b>
- *
- * <p> Request bodies are sent using one of the request processor implementations
- * below provided in {@code HttpRequest}, or else a custom implementation can be
- * used.
- * <ul>
- * <li>{@link #fromByteArray(byte[]) } from byte array</li>
- * <li>{@link #fromByteArrays(java.util.Iterator) fromByteArrays(Iterator)}
- *      from an iterator of byte arrays</li>
- * <li>{@link #fromFile(java.nio.file.Path) fromFile(Path)} from the file located
- *     at the given Path</li>
- * <li>{@link #fromString(java.lang.String) fromString(String)} from a String </li>
- * <li>{@link #fromInputStream(java.io.InputStream) fromInputStream(InputStream)}
- *      request body from InputStream</li>
- * <li>{@link #noBody() } no request body is sent</li>
- * </ul>
- *
- * <p> <b>Response bodies</b>
- *
- * <p> Responses bodies are handled by the {@link HttpResponse.BodyProcessor}
- * {@code <T>} supplied to the {@link HttpResponse#body(HttpResponse.BodyProcessor)
- * HttpResponse.body} and {@link HttpResponse#bodyAsync(HttpResponse.BodyProcessor)
- * HttpResponse.bodyAsync} methods. Some implementations of {@code
- * HttpResponse.BodyProcessor} are provided in {@link HttpResponse}:
- * <ul>
- * <li>{@link HttpResponse#asByteArray() } stores the body in a byte array</li>
- * <li>{@link HttpResponse#asString()} stores the body as a String </li>
- * <li>{@link HttpResponse#asFile(java.nio.file.Path) } stores the body in a
- * named file</li>
- * <li>{@link HttpResponse#ignoreBody() } ignores any received response body</li>
- * </ul>
- *
- * <p> The output of a response processor is the response body, and its
- * parameterized type {@code T} determines the type of the body object returned
- * from {@code HttpResponse.body} and {@code HttpResponse.bodyAsync}. Therefore,
- * as an example, the second response processor in the list above has the type
- * {@code HttpResponse.BodyProcessor<String>} which means the type returned by
- * {@code HttpResponse.body()} is a String. Response processors can be defined
- * to return potentially any type as body.
- *
- * <p> <b>Multi responses</b>
- *
- * <p> With HTTP/2 it is possible for a server to return a main response and zero
- * or more additional responses (known as server pushes) to a client-initiated
- * request. These are handled using a special response processor called {@link
- * HttpResponse.MultiProcessor}.
- *
- * <p> <b>Blocking/asynchronous behavior and thread usage</b>
- *
- * <p> There are two styles of request sending: <i>synchronous</i> and
- * <i>asynchronous</i>. {@link #response() response} blocks the calling thread
- * until the request has been sent and the response received.
- *
- * <p> {@link #responseAsync() responseAsync} is asynchronous and returns
- * immediately with a {@link java.util.concurrent.CompletableFuture}&lt;{@link
- * HttpResponse}&gt; and when this object completes (in a background thread) the
- * response has been received.
- *
- * <p> {@link #multiResponseAsync(HttpResponse.MultiProcessor) multiResponseAsync}
- * is the variant for multi responses and is also asynchronous.
- *
- * <p> CompletableFutures can be combined in different ways to declare the
- * dependencies among several asynchronous tasks, while allowing for the maximum
- * level of parallelism to be utilized.
- *
- * <p> <b>Security checks</b>
- *
- * <p> If a security manager is present then security checks are performed by
- * the {@link #response() } and {@link #responseAsync() } methods. A {@link
- * java.net.URLPermission} or {@link java.net.SocketPermission} is required to
- * access any destination origin server and proxy server utilised. URLPermissions
- * should be preferred in policy files over SocketPermissions given the more
- * limited scope of URLPermission. Permission is always implicitly granted to a
- * system's default proxies. The URLPermission form used to access proxies uses
- * a method parameter of "CONNECT" (for all kinds of proxying) and a url string
- * of the form "socket://host:port" where host and port specify the proxy's
- * address.
- *
- * <p> <b>Examples</b>
- * <pre>
- *     import static java.net.http.HttpRequest.*;
- *     import static java.net.http.HttpResponse.*;
- *
- *     //Simple blocking
- *
- *     HttpResponse r1 = HttpRequest.create(new URI("http://www.foo.com/"))
- *                                  .GET()
- *                                 .response();
- *     int responseCode = r1.statusCode());
- *     String body = r1.body(asString());
- *
- *     HttpResponse r2 = HttpRequest.create(new URI("http://www.foo.com/"))
- *                                  .GET()
- *                                  .response();
- *
- *     System.out.println("Response was " + r1.statusCode());
- *     Path body1 = r2.body(asFile(Paths.get("/tmp/response.txt")));
- *     // Content stored in /tmp/response.txt
- *
- *     HttpResponse r3 = HttpRequest.create(new URI("http://www.foo.com/"))
- *                                  .body(fromString("param1=1, param2=2"))
- *                                  .POST()
- *                                  .response();
- *
- *     Void body2 = r3.body(ignoreBody()); // body is Void in this case
- * </pre>
- *
- * <p><b>Asynchronous Example</b>
- *
- * <p> All of the above examples will work asynchronously, if {@link
- * #responseAsync()} is used instead of {@link #response()} in which case the
- * returned object is a {@code CompletableFuture<HttpResponse>} instead of
- * {@code HttpResponse}. The following example shows how multiple requests can
- * be sent asynchronously. It also shows how dependent asynchronous operations
- * (receiving response, and receiving response body) can be chained easily using
- * one of the many methods in {@code CompletableFuture}.
- * <pre>
- * {@code
- *      // fetch a list of target URIs asynchronously and store them in Files.
- *
- *      List<URI> targets = ...
- *
- *      List<CompletableFuture<File>> futures = targets
- *          .stream()
- *          .map(target -> {
- *              return HttpRequest
- *                  .create(target)
- *                  .GET()
- *                  .responseAsync()
- *                  .thenCompose(response -> {
- *                      Path dest = Paths.get("base", target.getPath());
- *                      if (response.statusCode() == 200) {
- *                          return response.bodyAsync(asFile(dest));
- *                      } else {
- *                          return CompletableFuture.completedFuture(dest);
- *                      }
- *                  })
- *                  // convert Path -> File
- *                  .thenApply((Path dest) -> {
- *                      return dest.toFile();
- *                  });
- *              })
- *          .collect(Collectors.toList());
- *
- *      // all async operations waited for here
- *
- *      CompletableFuture.allOf(futures.toArray(new CompletableFuture<?>[0]))
- *          .join();
- *
- *      // all elements of futures have completed and can be examined.
- *      // Use File.exists() to check whether file was successfully downloaded
- * }
- * </pre>
- *
- * @since 9
- */
-public abstract class HttpRequest {
-
-    HttpRequest() {}
-
-    /**
-     * A builder of {@link HttpRequest}s. {@code HttpRequest.Builder}s are
-     * created by calling {@link HttpRequest#create(URI)} or {@link
-     * HttpClient#request(URI)}.
-     *
-     * <p> Each of the setter methods in this class modifies the state of the
-     * builder and returns <i>this</i> (ie. the same instance). The methods are
-     * not synchronized and should not be called from multiple threads without
-     * external synchronization.
-     *
-     * <p> The build methods return a new {@code HttpRequest} each time they are
-     * called.
-     *
-     * @since 9
-     */
-    public abstract static class Builder {
-
-        Builder() {}
-
-        /**
-         * Sets this HttpRequest's request URI.
-         *
-         * @param uri the request URI
-         * @return this request builder
-         */
-        public abstract Builder uri(URI uri);
-
-        /**
-         * Specifies whether this request will automatically follow redirects
-         * issued by the server. The default value for this setting is the value
-         * of {@link HttpClient#followRedirects() }
-         *
-         * @param policy the redirection policy
-         * @return this request builder
-         */
-        public abstract Builder followRedirects(HttpClient.Redirect policy);
-
-        /**
-         * Request server to acknowledge request before sending request
-         * body. This is disabled by default. If enabled, the server is requested
-         * to send an error response or a 100-Continue response before the client
-         * sends the request body. This means the request processor for the
-         * request will not be invoked until this interim response is received.
-         *
-         * @param enable {@code true} if Expect continue to be sent
-         * @return this request builder
-         */
-        public abstract Builder expectContinue(boolean enable);
-
-        /**
-         * Overrides the {@link HttpClient#version()  } setting for this
-         * request.
-         *
-         * @param version the HTTP protocol version requested
-         * @return this request builder
-         */
-        public abstract Builder version(HttpClient.Version version);
-
-        /**
-         * Adds the given name value pair to the set of headers for this request.
-         *
-         * @param name the header name
-         * @param value the header value
-         * @return this request builder
-         */
-        public abstract Builder header(String name, String value);
-
-        /**
-         * Overrides the ProxySelector set on the request's client for this
-         * request.
-         *
-         * @param proxy the ProxySelector to use
-         * @return this request builder
-         */
-        public abstract Builder proxy(ProxySelector proxy);
-
-        /**
-         * Adds the given name value pairs to the set of headers for this
-         * request. The supplied Strings must alternate as names and values.
-         *
-         * @param headers the list of String name value pairs
-         * @return this request builder
-         * @throws IllegalArgumentException if there is an odd number of
-         *                                  parameters
-         */
-        public abstract Builder headers(String... headers);
-
-        /**
-         * Sets a timeout for this request. If the response is not received
-         * within the specified timeout then a {@link HttpTimeoutException} is
-         * thrown from {@link #response() } or {@link #responseAsync() }
-         * completes exceptionally with a {@code HttpTimeoutException}.
-         *
-         * @param unit the timeout units
-         * @param timeval the number of units to wait for
-         * @return this request builder
-         */
-        public abstract Builder timeout(TimeUnit unit, long timeval);
-
-        /**
-         * Sets the given name value pair to the set of headers for this
-         * request. This overwrites any previously set values for name.
-         *
-         * @param name the header name
-         * @param value the header value
-         * @return this request builder
-         */
-        public abstract Builder setHeader(String name, String value);
-
-        /**
-         * Sets a request body for this builder. See {@link HttpRequest}
-         * for example {@code BodyProcessor} implementations.
-         * If no body is specified, then no body is sent with the request.
-         *
-         * @param reqproc the request body processor
-         * @return this request builder
-         */
-        public abstract Builder body(BodyProcessor reqproc);
-
-        /**
-         * Builds and returns a GET {@link HttpRequest} from this builder.
-         *
-         * @return a {@code HttpRequest}
-         */
-        public abstract HttpRequest GET();
-
-        /**
-         * Builds and returns a POST {@link HttpRequest} from this builder.
-         *
-         * @return a {@code HttpRequest}
-         */
-        public abstract HttpRequest POST();
-
-        /**
-         * Builds and returns a PUT {@link HttpRequest} from this builder.
-         *
-         * @return a {@code HttpRequest}
-         */
-        public abstract HttpRequest PUT();
-
-        /**
-         * Builds and returns a {@link HttpRequest} from this builder using
-         * the given method String. The method string is case-sensitive, and
-         * may be rejected if an upper-case string is not used.
-         *
-         * @param method the method to use
-         * @return a {@code HttpRequest}
-         * @throws IllegalArgumentException if an unrecognised method is used
-         */
-        public abstract HttpRequest method(String method);
-
-        /**
-         * Returns an exact duplicate copy of this Builder based on current
-         * state. The new builder can then be modified independently of this
-         * builder.
-         *
-         * @return an exact copy of this Builder
-         */
-        public abstract Builder copy();
-    }
-
-    /**
-     * Creates a HttpRequest builder from the <i>default</i> HttpClient.
-     *
-     * @param uri the request URI
-     * @return a new request builder
-     */
-    public static HttpRequest.Builder create(URI uri) {
-        return HttpClient.getDefault().request(uri);
-    }
-
-    /**
-     * Returns the follow-redirects setting for this request.
-     *
-     * @return follow redirects setting
-     */
-    public abstract HttpClient.Redirect followRedirects();
-
-    /**
-     * Returns the response to this request, by sending it and blocking if
-     * necessary to get the response. The {@link HttpResponse} contains the
-     * response status and headers.
-     *
-     * @return a HttpResponse for this request
-     * @throws IOException if an I/O error occurs
-     * @throws InterruptedException if the operation was interrupted
-     * @throws SecurityException if the caller does not have the required
-     *                           permission
-     * @throws IllegalStateException if called more than once or if
-     *                               responseAsync() called previously
-     */
-    public abstract HttpResponse response()
-        throws IOException, InterruptedException;
-
-    /**
-     * Sends the request and returns the response asynchronously. This method
-     * returns immediately with a {@link CompletableFuture}&lt;{@link
-     * HttpResponse}&gt;
-     *
-     * @return a {@code CompletableFuture<HttpResponse>}
-     * @throws IllegalStateException if called more than once or if response()
-     *                               called previously.
-     */
-    public abstract CompletableFuture<HttpResponse> responseAsync();
-
-    /**
-     * Sends the request asynchronously expecting multiple responses.
-     *
-     * <p> This method must be given a {@link HttpResponse.MultiProcessor} to
-     * handle the multiple responses.
-     *
-     * <p> If a security manager is set, the caller must possess a {@link
-     * java.net.URLPermission} for the request's URI, method and any user set
-     * headers. The security manager is also checked for each incoming
-     * additional server generated request/response. Any request that fails the
-     * security check, is canceled and ignored.
-     *
-     * <p> This method can be used for both HTTP/1.1 and HTTP/2, but in cases
-     * where multiple responses are not supported, the MultiProcessor
-     * only receives the main response.
-     *
-     * <p> The aggregate {@code CompletableFuture} returned from this method
-     * returns a {@code <U>} defined by the {@link HttpResponse.MultiProcessor}
-     * implementation supplied. This will typically be a Collection of
-     * HttpResponses or of some response body type.
-     *
-     * @param <U> the aggregate response type
-     * @param rspproc the MultiProcessor for the request
-     * @return a {@code CompletableFuture<U>}
-     * @throws IllegalStateException if the request has already been sent.
-     */
-    public abstract <U> CompletableFuture<U>
-    multiResponseAsync(HttpResponse.MultiProcessor<U> rspproc);
-
-    /**
-     * Returns the request method for this request. If not set explicitly,
-     * the default method for any request is "GET".
-     *
-     * @return this request's method
-     */
-    public abstract String method();
-
-    /**
-     * Returns this request's {@link HttpRequest.Builder#expectContinue(boolean)
-     * expect continue } setting.
-     *
-     * @return this request's expect continue setting
-     */
-    public abstract boolean expectContinue();
-
-    /**
-     * Returns this request's request URI.
-     *
-     * @return this request's URI
-     */
-    public abstract URI uri();
-
-    /**
-     * Returns this request's {@link HttpClient}.
-     *
-     * @return this request's HttpClient
-     */
-    public abstract HttpClient client();
-
-    /**
-     * Returns the HTTP protocol version that this request will use or used.
-     *
-     * @return HTTP protocol version
-     */
-    public abstract HttpClient.Version version();
-
-    /**
-     * The (user-accessible) request headers that this request was (or will be)
-     * sent with.
-     *
-     * @return this request's HttpHeaders
-     */
-    public abstract HttpHeaders headers();
-
-    /**
-     * Returns a request processor whose body is the given String, converted
-     * using the {@link java.nio.charset.StandardCharsets#ISO_8859_1 ISO_8859_1}
-     * character set.
-     *
-     * @param body the String containing the body
-     * @return a BodyProcessor
-     */
-    public static BodyProcessor fromString(String body) {
-        return fromString(body, StandardCharsets.ISO_8859_1);
-    }
-
-    /**
-     * A request processor that takes data from the contents of a File.
-     *
-     * @param path the path to the file containing the body
-     * @return a BodyProcessor
-     */
-    public static BodyProcessor fromFile(Path path) {
-        FileChannel fc;
-        long size;
-
-        try {
-            fc = FileChannel.open(path);
-            size = fc.size();
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-
-        return new BodyProcessor() {
-            LongConsumer flow;
-
-            @Override
-            public long onRequestStart(HttpRequest hr, LongConsumer flow) {
-                // could return e