src/java.net.http/share/classes/jdk/internal/net/http/Stream.java
changeset 52554 5f1ca46703f9
parent 52499 768b1c612100
child 53467 97cf88608d76
child 53698 68ca8b201925
--- a/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java	Wed Nov 14 17:16:44 2018 +0530
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Stream.java	Wed Nov 14 14:23:21 2018 +0000
@@ -608,8 +608,20 @@
         if (contentLength > 0) {
             h.setHeader("content-length", Long.toString(contentLength));
         }
+        URI uri = request.uri();
+        if (uri != null) {
+            h.setHeader("host", Utils.hostString(request));
+        }
         HttpHeaders sysh = filterHeaders(h.build());
         HttpHeaders userh = filterHeaders(request.getUserHeaders());
+        // Filter context restricted from userHeaders
+        userh = HttpHeaders.of(userh.map(), Utils.CONTEXT_RESTRICTED(client()));
+
+        final HttpHeaders uh = userh;
+
+        // Filter any headers from systemHeaders that are set in userHeaders
+        sysh = HttpHeaders.of(sysh.map(), (k,v) -> uh.firstValue(k).isEmpty());
+
         OutgoingHeaders<Stream<T>> f = new OutgoingHeaders<>(sysh, userh, this);
         if (contentLength == 0) {
             f.setFlag(HeadersFrame.END_STREAM);