< prev index next >

src/java.net.http/share/classes/jdk/internal/net/http/Http1Request.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2015, 2017, 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 --- 1,7 ---- /* ! * Copyright (c) 2015, 2018, 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
*** 21,31 **** * 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 jdk.incubator.http; import java.io.IOException; import java.lang.System.Logger.Level; import java.net.URI; import java.nio.ByteBuffer; --- 21,31 ---- * 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 jdk.internal.net.http; import java.io.IOException; import java.lang.System.Logger.Level; import java.net.URI; import java.nio.ByteBuffer;
*** 33,47 **** import java.util.List; import java.util.Map; import java.net.InetSocketAddress; import java.util.Objects; import java.util.concurrent.Flow; ! ! import jdk.incubator.http.Http1Exchange.Http1BodySubscriber; ! import jdk.incubator.http.internal.common.HttpHeadersImpl; ! import jdk.incubator.http.internal.common.Log; ! import jdk.incubator.http.internal.common.Utils; import static java.nio.charset.StandardCharsets.US_ASCII; /** * An HTTP/1.1 request. --- 33,49 ---- import java.util.List; import java.util.Map; import java.net.InetSocketAddress; import java.util.Objects; import java.util.concurrent.Flow; ! import java.util.function.BiPredicate; ! import java.net.http.HttpHeaders; ! import java.net.http.HttpRequest; ! import jdk.internal.net.http.Http1Exchange.Http1BodySubscriber; ! import jdk.internal.net.http.common.HttpHeadersImpl; ! import jdk.internal.net.http.common.Log; ! import jdk.internal.net.http.common.Utils; import static java.nio.charset.StandardCharsets.US_ASCII; /** * An HTTP/1.1 request.
*** 79,98 **** String s = completeHeaders.replaceAll("\r\n", "\n"); Log.logHeaders("REQUEST HEADERS:\n" + s); } } private void collectHeaders0(StringBuilder sb) { ! collectHeaders1(sb, systemHeaders); ! collectHeaders1(sb, userHeaders); sb.append("\r\n"); } ! private void collectHeaders1(StringBuilder sb, HttpHeaders headers) { for (Map.Entry<String,List<String>> entry : headers.map().entrySet()) { String key = entry.getKey(); List<String> values = entry.getValue(); for (String value : values) { sb.append(key).append(": ").append(value).append("\r\n"); } } } --- 81,114 ---- String s = completeHeaders.replaceAll("\r\n", "\n"); Log.logHeaders("REQUEST HEADERS:\n" + s); } } + private void collectHeaders0(StringBuilder sb) { ! BiPredicate<String,List<String>> filter = ! connection.headerFilter(request); ! ! // If we're sending this request through a tunnel, ! // then don't send any preemptive proxy-* headers that ! // the authentication filter may have saved in its ! // cache. ! collectHeaders1(sb, systemHeaders, filter); ! ! // If we're sending this request through a tunnel, ! // don't send any user-supplied proxy-* headers ! // to the target server. ! collectHeaders1(sb, userHeaders, filter); sb.append("\r\n"); } ! private void collectHeaders1(StringBuilder sb, HttpHeaders headers, ! BiPredicate<String, List<String>> filter) { for (Map.Entry<String,List<String>> entry : headers.map().entrySet()) { String key = entry.getKey(); List<String> values = entry.getValue(); + if (!filter.test(key, values)) continue; for (String value : values) { sb.append(key).append(": ").append(value).append("\r\n"); } } }
*** 186,196 **** URI uri = request.uri(); if (uri != null) { systemHeaders.setHeader("Host", hostString()); } ! if (request == null || requestPublisher == null) { // Not a user request, or maybe a method, e.g. GET, with no body. contentLength = 0; } else { contentLength = requestPublisher.contentLength(); } --- 202,212 ---- URI uri = request.uri(); if (uri != null) { systemHeaders.setHeader("Host", hostString()); } ! if (requestPublisher == null) { // Not a user request, or maybe a method, e.g. GET, with no body. contentLength = 0; } else { contentLength = requestPublisher.contentLength(); }
< prev index next >