# HG changeset patch # User michaelm # Date 1516374327 0 # Node ID c52c9a3a204633582a73f7cff522bbb62e70abc7 # Parent 1f88e15870671376b7b4f273af5ac2758e3bc127 http-client-branch: make PushPromiseHandlerMap package private diff -r 1f88e1587067 -r c52c9a3a2046 src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpResponse.java --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpResponse.java Thu Jan 18 19:51:17 2018 +0000 +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpResponse.java Fri Jan 19 15:05:27 2018 +0000 @@ -209,6 +209,51 @@ } } + /* package-private with push promise Map implementation */ + static class PushPromisesHandlerWithMap implements PushPromiseHandler { + + private final ConcurrentMap>> pushPromisesMap; + private final Function> pushPromiseHandler; + + PushPromisesHandlerWithMap(Function> pushPromiseHandler, + ConcurrentMap>> pushPromisesMap) { + this.pushPromiseHandler = pushPromiseHandler; + this.pushPromisesMap = pushPromisesMap; + } + + @Override + public void applyPushPromise( + HttpRequest initiatingRequest, HttpRequest pushRequest, + Function,CompletableFuture>> acceptor) + { + URI initiatingURI = initiatingRequest.uri(); + URI pushRequestURI = pushRequest.uri(); + if (!initiatingURI.getHost().equalsIgnoreCase(pushRequestURI.getHost())) + return; + + int initiatingPort = initiatingURI.getPort(); + if (initiatingPort == -1 ) { + if ("https".equalsIgnoreCase(initiatingURI.getScheme())) + initiatingPort = 443; + else + initiatingPort = 80; + } + int pushPort = pushRequestURI.getPort(); + if (pushPort == -1 ) { + if ("https".equalsIgnoreCase(pushRequestURI.getScheme())) + pushPort = 443; + else + pushPort = 80; + } + if (initiatingPort != pushPort) + return; + + CompletableFuture> cf = + acceptor.apply(pushPromiseHandler.apply(pushRequest)); + pushPromisesMap.put(pushRequest, cf); + } + } + // Similar to Path body handler, but for file download. Supports setting ACC. static class FileDownloadBodyHandler implements UntrustedBodyHandler { private final Path directory; @@ -772,51 +817,6 @@ ); - /* package-private with push promise Map implementation */ - static class PushPromisesHandlerWithMap implements PushPromiseHandler { - - private final ConcurrentMap>> pushPromisesMap; - private final Function> pushPromiseHandler; - - PushPromisesHandlerWithMap(Function> pushPromiseHandler, - ConcurrentMap>> pushPromisesMap) { - this.pushPromiseHandler = pushPromiseHandler; - this.pushPromisesMap = pushPromisesMap; - } - - @Override - public void applyPushPromise( - HttpRequest initiatingRequest, HttpRequest pushRequest, - Function,CompletableFuture>> acceptor) - { - URI initiatingURI = initiatingRequest.uri(); - URI pushRequestURI = pushRequest.uri(); - if (!initiatingURI.getHost().equalsIgnoreCase(pushRequestURI.getHost())) - return; - - int initiatingPort = initiatingURI.getPort(); - if (initiatingPort == -1 ) { - if ("https".equalsIgnoreCase(initiatingURI.getScheme())) - initiatingPort = 443; - else - initiatingPort = 80; - } - int pushPort = pushRequestURI.getPort(); - if (pushPort == -1 ) { - if ("https".equalsIgnoreCase(pushRequestURI.getScheme())) - pushPort = 443; - else - pushPort = 80; - } - if (initiatingPort != pushPort) - return; - - CompletableFuture> cf = - acceptor.apply(pushPromiseHandler.apply(pushRequest)); - pushPromisesMap.put(pushRequest, cf); - } - } - /** * Returns a push promise handler that accumulates push promises, and * their responses, into the given map.