src/java.base/share/classes/sun/net/www/MessageHeader.java
branchJDK-8229867-branch
changeset 57968 8595871a5446
parent 57713 0211b062843d
equal deleted inserted replaced
57966:e89c7aaf2906 57968:8595871a5446
     1 /*
     1 /*
     2  * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   309         if (c3 < '0' || c3 > '9') return false;
   309         if (c3 < '0' || c3 > '9') return false;
   310 
   310 
   311         return (k.substring(i+1, len-3).equalsIgnoreCase("HTTP/"));
   311         return (k.substring(i+1, len-3).equalsIgnoreCase("HTTP/"));
   312     }
   312     }
   313 
   313 
   314 
       
   315     /** Prints the key-value pairs represented by this
   314     /** Prints the key-value pairs represented by this
   316         header. Also prints the RFC required blank line
   315         header. Also prints the RFC required blank line
   317         at the end. Omits pairs with a null key. Omits
   316         at the end. Omits pairs with a null key. Omits
   318         colon if key-value pair is the requestline. */
   317         colon if key-value pair is the requestline. */
   319     public synchronized void print(PrintStream p) {
   318     public void print(PrintStream p) {
       
   319         // no synchronization: use cloned arrays instead.
       
   320         String[] k; String[] v; int n;
       
   321         synchronized (this) { n = nkeys; k = keys.clone(); v = values.clone(); }
       
   322         print(n, k, v, p);
       
   323     }
       
   324 
       
   325 
       
   326     /** Prints the key-value pairs represented by this
       
   327         header. Also prints the RFC required blank line
       
   328         at the end. Omits pairs with a null key. Omits
       
   329         colon if key-value pair is the requestline. */
       
   330     private  void print(int nkeys, String[] keys, String[] values, PrintStream p) {
   320         for (int i = 0; i < nkeys; i++)
   331         for (int i = 0; i < nkeys; i++)
   321             if (keys[i] != null) {
   332             if (keys[i] != null) {
   322                 StringBuilder sb = new StringBuilder(keys[i]);
   333                 StringBuilder sb = new StringBuilder(keys[i]);
   323                 if (values[i] != null) {
   334                 if (values[i] != null) {
   324                     sb.append(": " + values[i]);
   335                     sb.append(": " + values[i]);