< prev index next >

src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/common/Log.java

Print this page

        

*** 1,7 **** /* ! * 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 --- 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
*** 23,43 **** * questions. */ package jdk.incubator.http.internal.common; - import java.io.IOException; import jdk.incubator.http.HttpHeaders; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.function.Supplier; import jdk.incubator.http.internal.frame.DataFrame; import jdk.incubator.http.internal.frame.Http2Frame; import jdk.incubator.http.internal.frame.WindowUpdateFrame; /** * -Djava.net.HttpClient.log= * errors,requests,headers, * frames[:control:data:window:all..],content,ssl,trace * --- 23,47 ---- * questions. */ package jdk.incubator.http.internal.common; import jdk.incubator.http.HttpHeaders; + + import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.function.Supplier; import jdk.incubator.http.internal.frame.DataFrame; import jdk.incubator.http.internal.frame.Http2Frame; import jdk.incubator.http.internal.frame.WindowUpdateFrame; + import javax.net.ssl.SNIServerName; + import javax.net.ssl.SSLParameters; + /** * -Djava.net.HttpClient.log= * errors,requests,headers, * frames[:control:data:window:all..],content,ssl,trace *
*** 194,206 **** if (requests()) { logger.log(Level.INFO, "REQUEST: " + s, s1); } } ! public static void logResponse(String s, Object... s1) { if (requests()) { ! logger.log(Level.INFO, "RESPONSE: " + s, s1); } } public static void logHeaders(String s, Object... s1) { if (headers()) { --- 198,210 ---- if (requests()) { logger.log(Level.INFO, "REQUEST: " + s, s1); } } ! public static void logResponse(Supplier<String> supplier) { if (requests()) { ! logger.log(Level.INFO, "RESPONSE: " + supplier.get()); } } public static void logHeaders(String s, Object... s1) { if (headers()) {
*** 225,234 **** --- 229,287 ---- if (frames() && loggingFrame(f.getClass())) { logger.log(Level.INFO, "FRAME: " + direction + ": " + f.toString()); } } + public static void logParams(SSLParameters p) { + if (!Log.ssl()) { + return; + } + + if (p == null) { + Log.logSSL("SSLParameters: Null params"); + return; + } + + final StringBuilder sb = new StringBuilder("SSLParameters:"); + final List<Object> params = new ArrayList<>(); + if (p.getCipherSuites() != null) { + for (String cipher : p.getCipherSuites()) { + sb.append("\n cipher: {") + .append(params.size()).append("}"); + params.add(cipher); + } + } + + // SSLParameters.getApplicationProtocols() can't return null + // JDK 8 EXCL START + for (String approto : p.getApplicationProtocols()) { + sb.append("\n application protocol: {") + .append(params.size()).append("}"); + params.add(approto); + } + // JDK 8 EXCL END + + if (p.getProtocols() != null) { + for (String protocol : p.getProtocols()) { + sb.append("\n protocol: {") + .append(params.size()).append("}"); + params.add(protocol); + } + } + + if (p.getServerNames() != null) { + for (SNIServerName sname : p.getServerNames()) { + sb.append("\n server name: {") + .append(params.size()).append("}"); + params.add(sname.toString()); + } + } + sb.append('\n'); + + Log.logSSL(sb.toString(), params.toArray()); + } + public static void dumpHeaders(StringBuilder sb, String prefix, HttpHeaders headers) { if (headers != null) { Map<String,List<String>> h = headers.map(); Set<Map.Entry<String,List<String>>> entries = h.entrySet(); for (Map.Entry<String,List<String>> entry : entries) {
< prev index next >