# HG changeset patch # User dfuchs # Date 1512562688 0 # Node ID ae2750657f98ead60fc322760e1284cbf8185af8 # Parent 7fd1a84f4faef64042a39db1bdf68b33b5eaa9ef# Parent 35376c843df1b88656ea759fbc463535a76b0022 Merge diff -r 35376c843df1 -r ae2750657f98 src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/BufferingSubscriber.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/BufferingSubscriber.java Wed Dec 06 10:44:31 2017 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/BufferingSubscriber.java Wed Dec 06 12:18:08 2017 +0000 @@ -89,8 +89,8 @@ } /** Returns the number of bytes remaining in the given buffers. */ - private static final int remaining(List buffers) { - return buffers.stream().mapToInt(ByteBuffer::remaining).sum(); + private static final long remaining(List buffers) { + return buffers.stream().mapToLong(ByteBuffer::remaining).sum(); } /** @@ -190,8 +190,8 @@ try { Throwable t = throwable; if (t != null) { + pushDemandedScheduler.stop(); // stop the demand scheduler downstreamSubscriber.onError(t); - pushDemandedScheduler.stop(); // stop the demand scheduler return; } @@ -219,8 +219,9 @@ complete = state == COMPLETE && internalBuffers.isEmpty(); } if (complete) { + assert internalBuffers.isEmpty(); + pushDemandedScheduler.stop(); // stop the demand scheduler downstreamSubscriber.onComplete(); - pushDemandedScheduler.stop(); // stop the demand scheduler return; } } catch (Throwable t) { diff -r 35376c843df1 -r ae2750657f98 src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequestImpl.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequestImpl.java Wed Dec 06 10:44:31 2017 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequestImpl.java Wed Dec 06 12:18:08 2017 +0000 @@ -59,6 +59,15 @@ private final Duration timeout; // may be null private final Optional version; + private static String userAgent() { + PrivilegedAction pa = () -> System.getProperty("java.version"); + String version = AccessController.doPrivileged(pa); + return "Java-http-client/" + version; + } + + /** The value of the User-Agent header for all requests sent by the client. */ + public static final String USER_AGENT = userAgent(); + /** * Creates an HttpRequestImpl from the given builder. */ @@ -90,6 +99,7 @@ } else { this.systemHeaders = new HttpHeadersImpl(); } + this.systemHeaders.setHeader("User-Agent", USER_AGENT); this.uri = request.uri(); if (isWebSocket) { // WebSocket determines and sets the proxy itself diff -r 35376c843df1 -r ae2750657f98 test/jdk/java/net/httpclient/SplitResponse.java --- a/test/jdk/java/net/httpclient/SplitResponse.java Wed Dec 06 10:44:31 2017 +0000 +++ b/test/jdk/java/net/httpclient/SplitResponse.java Wed Dec 06 12:18:08 2017 +0000 @@ -137,7 +137,7 @@ // MockServer will reject rogue requests whose URI does not // contain "/foo/". // - // Thread go = new Thread() { + // Thread rogue = new Thread() { // public void run() { // try { // HttpClient client = newHttpClient(); @@ -156,8 +156,8 @@ // } // } // }; - // go.setDaemon(true); - // go.start(); + // rogue.setDaemon(true); + // rogue.start(); HttpClient client = newHttpClient();