test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/HuffmanTest.java
author chegar
Wed, 20 Jun 2018 18:23:56 +0100
branchhttp-client-branch
changeset 56795 03ece2518428
parent 56623 1d020b5d73f1
parent 50681 4254bed3c09d
permissions -rw-r--r--
http-client-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
     1
/*
49765
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents: 48083
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
     4
 *
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
     8
 *
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    13
 * accompanied this code).
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    14
 *
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    18
 *
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    21
 * questions.
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    22
 */
49765
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents: 48083
diff changeset
    23
package jdk.internal.net.http.hpack;
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    24
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    25
import jdk.internal.net.http.hpack.Huffman.Reader;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    26
import jdk.internal.net.http.hpack.Huffman.Writer;
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    27
import org.testng.annotations.Test;
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    28
48083
b1c1b4ef4be2 8191494: Refresh incubating HTTP Client
chegar
parents: 47216
diff changeset
    29
import java.io.IOException;
b1c1b4ef4be2 8191494: Refresh incubating HTTP Client
chegar
parents: 47216
diff changeset
    30
import java.io.UncheckedIOException;
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    31
import java.nio.ByteBuffer;
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    32
import java.util.HashMap;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    33
import java.util.Map;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    34
import java.util.Objects;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    35
import java.util.SortedMap;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    36
import java.util.TreeMap;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    37
import java.util.function.Supplier;
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    38
import java.util.regex.Matcher;
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    39
import java.util.regex.Pattern;
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    40
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    41
import static jdk.internal.net.http.hpack.HPACK.bytesForBits;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    42
import static org.testng.Assert.assertEquals;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    43
import static org.testng.Assert.assertTrue;
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    44
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    45
public final class HuffmanTest {
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    46
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    47
    /*
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    48
     * Implementations of Huffman.Reader and Huffman.Writer under test.
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    49
     * Change them here.
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    50
     */
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    51
    private static final Supplier<Reader> READER = QuickHuffman.Reader::new;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    52
    private static final Supplier<Writer> WRITER = QuickHuffman.Writer::new;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    53
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    54
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    55
    // https://tools.ietf.org/html/rfc7541#appendix-B
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    56
    //
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
    57
    private static final String SPECIFICATION =
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    58
            // @formatter:off
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    59
     "                          code as bits                 as hex   len\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    60
     "        sym              aligned to MSB                aligned   in\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    61
     "                                                       to LSB   bits\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    62
     "       (  0)  |11111111|11000                             1ff8  [13]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    63
     "       (  1)  |11111111|11111111|1011000                7fffd8  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    64
     "       (  2)  |11111111|11111111|11111110|0010         fffffe2  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    65
     "       (  3)  |11111111|11111111|11111110|0011         fffffe3  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    66
     "       (  4)  |11111111|11111111|11111110|0100         fffffe4  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    67
     "       (  5)  |11111111|11111111|11111110|0101         fffffe5  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    68
     "       (  6)  |11111111|11111111|11111110|0110         fffffe6  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    69
     "       (  7)  |11111111|11111111|11111110|0111         fffffe7  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    70
     "       (  8)  |11111111|11111111|11111110|1000         fffffe8  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    71
     "       (  9)  |11111111|11111111|11101010               ffffea  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    72
     "       ( 10)  |11111111|11111111|11111111|111100      3ffffffc  [30]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    73
     "       ( 11)  |11111111|11111111|11111110|1001         fffffe9  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    74
     "       ( 12)  |11111111|11111111|11111110|1010         fffffea  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    75
     "       ( 13)  |11111111|11111111|11111111|111101      3ffffffd  [30]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    76
     "       ( 14)  |11111111|11111111|11111110|1011         fffffeb  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    77
     "       ( 15)  |11111111|11111111|11111110|1100         fffffec  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    78
     "       ( 16)  |11111111|11111111|11111110|1101         fffffed  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    79
     "       ( 17)  |11111111|11111111|11111110|1110         fffffee  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    80
     "       ( 18)  |11111111|11111111|11111110|1111         fffffef  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    81
     "       ( 19)  |11111111|11111111|11111111|0000         ffffff0  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    82
     "       ( 20)  |11111111|11111111|11111111|0001         ffffff1  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    83
     "       ( 21)  |11111111|11111111|11111111|0010         ffffff2  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    84
     "       ( 22)  |11111111|11111111|11111111|111110      3ffffffe  [30]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    85
     "       ( 23)  |11111111|11111111|11111111|0011         ffffff3  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    86
     "       ( 24)  |11111111|11111111|11111111|0100         ffffff4  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    87
     "       ( 25)  |11111111|11111111|11111111|0101         ffffff5  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    88
     "       ( 26)  |11111111|11111111|11111111|0110         ffffff6  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    89
     "       ( 27)  |11111111|11111111|11111111|0111         ffffff7  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    90
     "       ( 28)  |11111111|11111111|11111111|1000         ffffff8  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    91
     "       ( 29)  |11111111|11111111|11111111|1001         ffffff9  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    92
     "       ( 30)  |11111111|11111111|11111111|1010         ffffffa  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    93
     "       ( 31)  |11111111|11111111|11111111|1011         ffffffb  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    94
     "   ' ' ( 32)  |010100                                       14  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    95
     "   '!' ( 33)  |11111110|00                                 3f8  [10]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    96
     "  '\"' ( 34)  |11111110|01                                 3f9  [10]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    97
     "   '#' ( 35)  |11111111|1010                               ffa  [12]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    98
     "   '$' ( 36)  |11111111|11001                             1ff9  [13]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
    99
     "   '%' ( 37)  |010101                                       15  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   100
     "   '&' ( 38)  |11111000                                     f8  [ 8]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   101
     "   ''' ( 39)  |11111111|010                                7fa  [11]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   102
     "   '(' ( 40)  |11111110|10                                 3fa  [10]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   103
     "   ')' ( 41)  |11111110|11                                 3fb  [10]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   104
     "   '*' ( 42)  |11111001                                     f9  [ 8]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   105
     "   '+' ( 43)  |11111111|011                                7fb  [11]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   106
     "   ',' ( 44)  |11111010                                     fa  [ 8]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   107
     "   '-' ( 45)  |010110                                       16  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   108
     "   '.' ( 46)  |010111                                       17  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   109
     "   '/' ( 47)  |011000                                       18  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   110
     "   '0' ( 48)  |00000                                         0  [ 5]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   111
     "   '1' ( 49)  |00001                                         1  [ 5]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   112
     "   '2' ( 50)  |00010                                         2  [ 5]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   113
     "   '3' ( 51)  |011001                                       19  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   114
     "   '4' ( 52)  |011010                                       1a  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   115
     "   '5' ( 53)  |011011                                       1b  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   116
     "   '6' ( 54)  |011100                                       1c  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   117
     "   '7' ( 55)  |011101                                       1d  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   118
     "   '8' ( 56)  |011110                                       1e  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   119
     "   '9' ( 57)  |011111                                       1f  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   120
     "   ':' ( 58)  |1011100                                      5c  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   121
     "   ';' ( 59)  |11111011                                     fb  [ 8]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   122
     "   '<' ( 60)  |11111111|1111100                           7ffc  [15]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   123
     "   '=' ( 61)  |100000                                       20  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   124
     "   '>' ( 62)  |11111111|1011                               ffb  [12]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   125
     "   '?' ( 63)  |11111111|00                                 3fc  [10]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   126
     "   '@' ( 64)  |11111111|11010                             1ffa  [13]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   127
     "   'A' ( 65)  |100001                                       21  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   128
     "   'B' ( 66)  |1011101                                      5d  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   129
     "   'C' ( 67)  |1011110                                      5e  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   130
     "   'D' ( 68)  |1011111                                      5f  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   131
     "   'E' ( 69)  |1100000                                      60  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   132
     "   'F' ( 70)  |1100001                                      61  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   133
     "   'G' ( 71)  |1100010                                      62  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   134
     "   'H' ( 72)  |1100011                                      63  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   135
     "   'I' ( 73)  |1100100                                      64  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   136
     "   'J' ( 74)  |1100101                                      65  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   137
     "   'K' ( 75)  |1100110                                      66  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   138
     "   'L' ( 76)  |1100111                                      67  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   139
     "   'M' ( 77)  |1101000                                      68  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   140
     "   'N' ( 78)  |1101001                                      69  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   141
     "   'O' ( 79)  |1101010                                      6a  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   142
     "   'P' ( 80)  |1101011                                      6b  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   143
     "   'Q' ( 81)  |1101100                                      6c  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   144
     "   'R' ( 82)  |1101101                                      6d  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   145
     "   'S' ( 83)  |1101110                                      6e  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   146
     "   'T' ( 84)  |1101111                                      6f  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   147
     "   'U' ( 85)  |1110000                                      70  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   148
     "   'V' ( 86)  |1110001                                      71  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   149
     "   'W' ( 87)  |1110010                                      72  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   150
     "   'X' ( 88)  |11111100                                     fc  [ 8]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   151
     "   'Y' ( 89)  |1110011                                      73  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   152
     "   'Z' ( 90)  |11111101                                     fd  [ 8]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   153
     "   '[' ( 91)  |11111111|11011                             1ffb  [13]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   154
     "  '\\' ( 92)  |11111111|11111110|000                     7fff0  [19]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   155
     "   ']' ( 93)  |11111111|11100                             1ffc  [13]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   156
     "   '^' ( 94)  |11111111|111100                            3ffc  [14]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   157
     "   '_' ( 95)  |100010                                       22  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   158
     "   '`' ( 96)  |11111111|1111101                           7ffd  [15]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   159
     "   'a' ( 97)  |00011                                         3  [ 5]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   160
     "   'b' ( 98)  |100011                                       23  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   161
     "   'c' ( 99)  |00100                                         4  [ 5]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   162
     "   'd' (100)  |100100                                       24  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   163
     "   'e' (101)  |00101                                         5  [ 5]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   164
     "   'f' (102)  |100101                                       25  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   165
     "   'g' (103)  |100110                                       26  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   166
     "   'h' (104)  |100111                                       27  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   167
     "   'i' (105)  |00110                                         6  [ 5]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   168
     "   'j' (106)  |1110100                                      74  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   169
     "   'k' (107)  |1110101                                      75  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   170
     "   'l' (108)  |101000                                       28  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   171
     "   'm' (109)  |101001                                       29  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   172
     "   'n' (110)  |101010                                       2a  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   173
     "   'o' (111)  |00111                                         7  [ 5]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   174
     "   'p' (112)  |101011                                       2b  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   175
     "   'q' (113)  |1110110                                      76  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   176
     "   'r' (114)  |101100                                       2c  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   177
     "   's' (115)  |01000                                         8  [ 5]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   178
     "   't' (116)  |01001                                         9  [ 5]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   179
     "   'u' (117)  |101101                                       2d  [ 6]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   180
     "   'v' (118)  |1110111                                      77  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   181
     "   'w' (119)  |1111000                                      78  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   182
     "   'x' (120)  |1111001                                      79  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   183
     "   'y' (121)  |1111010                                      7a  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   184
     "   'z' (122)  |1111011                                      7b  [ 7]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   185
     "   '{' (123)  |11111111|1111110                           7ffe  [15]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   186
     "   '|' (124)  |11111111|100                                7fc  [11]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   187
     "   '}' (125)  |11111111|111101                            3ffd  [14]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   188
     "   '~' (126)  |11111111|11101                             1ffd  [13]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   189
     "       (127)  |11111111|11111111|11111111|1100         ffffffc  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   190
     "       (128)  |11111111|11111110|0110                    fffe6  [20]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   191
     "       (129)  |11111111|11111111|010010                 3fffd2  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   192
     "       (130)  |11111111|11111110|0111                    fffe7  [20]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   193
     "       (131)  |11111111|11111110|1000                    fffe8  [20]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   194
     "       (132)  |11111111|11111111|010011                 3fffd3  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   195
     "       (133)  |11111111|11111111|010100                 3fffd4  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   196
     "       (134)  |11111111|11111111|010101                 3fffd5  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   197
     "       (135)  |11111111|11111111|1011001                7fffd9  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   198
     "       (136)  |11111111|11111111|010110                 3fffd6  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   199
     "       (137)  |11111111|11111111|1011010                7fffda  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   200
     "       (138)  |11111111|11111111|1011011                7fffdb  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   201
     "       (139)  |11111111|11111111|1011100                7fffdc  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   202
     "       (140)  |11111111|11111111|1011101                7fffdd  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   203
     "       (141)  |11111111|11111111|1011110                7fffde  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   204
     "       (142)  |11111111|11111111|11101011               ffffeb  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   205
     "       (143)  |11111111|11111111|1011111                7fffdf  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   206
     "       (144)  |11111111|11111111|11101100               ffffec  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   207
     "       (145)  |11111111|11111111|11101101               ffffed  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   208
     "       (146)  |11111111|11111111|010111                 3fffd7  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   209
     "       (147)  |11111111|11111111|1100000                7fffe0  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   210
     "       (148)  |11111111|11111111|11101110               ffffee  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   211
     "       (149)  |11111111|11111111|1100001                7fffe1  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   212
     "       (150)  |11111111|11111111|1100010                7fffe2  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   213
     "       (151)  |11111111|11111111|1100011                7fffe3  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   214
     "       (152)  |11111111|11111111|1100100                7fffe4  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   215
     "       (153)  |11111111|11111110|11100                  1fffdc  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   216
     "       (154)  |11111111|11111111|011000                 3fffd8  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   217
     "       (155)  |11111111|11111111|1100101                7fffe5  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   218
     "       (156)  |11111111|11111111|011001                 3fffd9  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   219
     "       (157)  |11111111|11111111|1100110                7fffe6  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   220
     "       (158)  |11111111|11111111|1100111                7fffe7  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   221
     "       (159)  |11111111|11111111|11101111               ffffef  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   222
     "       (160)  |11111111|11111111|011010                 3fffda  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   223
     "       (161)  |11111111|11111110|11101                  1fffdd  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   224
     "       (162)  |11111111|11111110|1001                    fffe9  [20]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   225
     "       (163)  |11111111|11111111|011011                 3fffdb  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   226
     "       (164)  |11111111|11111111|011100                 3fffdc  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   227
     "       (165)  |11111111|11111111|1101000                7fffe8  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   228
     "       (166)  |11111111|11111111|1101001                7fffe9  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   229
     "       (167)  |11111111|11111110|11110                  1fffde  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   230
     "       (168)  |11111111|11111111|1101010                7fffea  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   231
     "       (169)  |11111111|11111111|011101                 3fffdd  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   232
     "       (170)  |11111111|11111111|011110                 3fffde  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   233
     "       (171)  |11111111|11111111|11110000               fffff0  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   234
     "       (172)  |11111111|11111110|11111                  1fffdf  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   235
     "       (173)  |11111111|11111111|011111                 3fffdf  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   236
     "       (174)  |11111111|11111111|1101011                7fffeb  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   237
     "       (175)  |11111111|11111111|1101100                7fffec  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   238
     "       (176)  |11111111|11111111|00000                  1fffe0  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   239
     "       (177)  |11111111|11111111|00001                  1fffe1  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   240
     "       (178)  |11111111|11111111|100000                 3fffe0  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   241
     "       (179)  |11111111|11111111|00010                  1fffe2  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   242
     "       (180)  |11111111|11111111|1101101                7fffed  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   243
     "       (181)  |11111111|11111111|100001                 3fffe1  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   244
     "       (182)  |11111111|11111111|1101110                7fffee  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   245
     "       (183)  |11111111|11111111|1101111                7fffef  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   246
     "       (184)  |11111111|11111110|1010                    fffea  [20]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   247
     "       (185)  |11111111|11111111|100010                 3fffe2  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   248
     "       (186)  |11111111|11111111|100011                 3fffe3  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   249
     "       (187)  |11111111|11111111|100100                 3fffe4  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   250
     "       (188)  |11111111|11111111|1110000                7ffff0  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   251
     "       (189)  |11111111|11111111|100101                 3fffe5  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   252
     "       (190)  |11111111|11111111|100110                 3fffe6  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   253
     "       (191)  |11111111|11111111|1110001                7ffff1  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   254
     "       (192)  |11111111|11111111|11111000|00           3ffffe0  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   255
     "       (193)  |11111111|11111111|11111000|01           3ffffe1  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   256
     "       (194)  |11111111|11111110|1011                    fffeb  [20]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   257
     "       (195)  |11111111|11111110|001                     7fff1  [19]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   258
     "       (196)  |11111111|11111111|100111                 3fffe7  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   259
     "       (197)  |11111111|11111111|1110010                7ffff2  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   260
     "       (198)  |11111111|11111111|101000                 3fffe8  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   261
     "       (199)  |11111111|11111111|11110110|0            1ffffec  [25]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   262
     "       (200)  |11111111|11111111|11111000|10           3ffffe2  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   263
     "       (201)  |11111111|11111111|11111000|11           3ffffe3  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   264
     "       (202)  |11111111|11111111|11111001|00           3ffffe4  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   265
     "       (203)  |11111111|11111111|11111011|110          7ffffde  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   266
     "       (204)  |11111111|11111111|11111011|111          7ffffdf  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   267
     "       (205)  |11111111|11111111|11111001|01           3ffffe5  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   268
     "       (206)  |11111111|11111111|11110001               fffff1  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   269
     "       (207)  |11111111|11111111|11110110|1            1ffffed  [25]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   270
     "       (208)  |11111111|11111110|010                     7fff2  [19]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   271
     "       (209)  |11111111|11111111|00011                  1fffe3  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   272
     "       (210)  |11111111|11111111|11111001|10           3ffffe6  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   273
     "       (211)  |11111111|11111111|11111100|000          7ffffe0  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   274
     "       (212)  |11111111|11111111|11111100|001          7ffffe1  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   275
     "       (213)  |11111111|11111111|11111001|11           3ffffe7  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   276
     "       (214)  |11111111|11111111|11111100|010          7ffffe2  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   277
     "       (215)  |11111111|11111111|11110010               fffff2  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   278
     "       (216)  |11111111|11111111|00100                  1fffe4  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   279
     "       (217)  |11111111|11111111|00101                  1fffe5  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   280
     "       (218)  |11111111|11111111|11111010|00           3ffffe8  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   281
     "       (219)  |11111111|11111111|11111010|01           3ffffe9  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   282
     "       (220)  |11111111|11111111|11111111|1101         ffffffd  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   283
     "       (221)  |11111111|11111111|11111100|011          7ffffe3  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   284
     "       (222)  |11111111|11111111|11111100|100          7ffffe4  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   285
     "       (223)  |11111111|11111111|11111100|101          7ffffe5  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   286
     "       (224)  |11111111|11111110|1100                    fffec  [20]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   287
     "       (225)  |11111111|11111111|11110011               fffff3  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   288
     "       (226)  |11111111|11111110|1101                    fffed  [20]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   289
     "       (227)  |11111111|11111111|00110                  1fffe6  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   290
     "       (228)  |11111111|11111111|101001                 3fffe9  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   291
     "       (229)  |11111111|11111111|00111                  1fffe7  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   292
     "       (230)  |11111111|11111111|01000                  1fffe8  [21]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   293
     "       (231)  |11111111|11111111|1110011                7ffff3  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   294
     "       (232)  |11111111|11111111|101010                 3fffea  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   295
     "       (233)  |11111111|11111111|101011                 3fffeb  [22]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   296
     "       (234)  |11111111|11111111|11110111|0            1ffffee  [25]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   297
     "       (235)  |11111111|11111111|11110111|1            1ffffef  [25]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   298
     "       (236)  |11111111|11111111|11110100               fffff4  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   299
     "       (237)  |11111111|11111111|11110101               fffff5  [24]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   300
     "       (238)  |11111111|11111111|11111010|10           3ffffea  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   301
     "       (239)  |11111111|11111111|1110100                7ffff4  [23]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   302
     "       (240)  |11111111|11111111|11111010|11           3ffffeb  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   303
     "       (241)  |11111111|11111111|11111100|110          7ffffe6  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   304
     "       (242)  |11111111|11111111|11111011|00           3ffffec  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   305
     "       (243)  |11111111|11111111|11111011|01           3ffffed  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   306
     "       (244)  |11111111|11111111|11111100|111          7ffffe7  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   307
     "       (245)  |11111111|11111111|11111101|000          7ffffe8  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   308
     "       (246)  |11111111|11111111|11111101|001          7ffffe9  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   309
     "       (247)  |11111111|11111111|11111101|010          7ffffea  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   310
     "       (248)  |11111111|11111111|11111101|011          7ffffeb  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   311
     "       (249)  |11111111|11111111|11111111|1110         ffffffe  [28]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   312
     "       (250)  |11111111|11111111|11111101|100          7ffffec  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   313
     "       (251)  |11111111|11111111|11111101|101          7ffffed  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   314
     "       (252)  |11111111|11111111|11111101|110          7ffffee  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   315
     "       (253)  |11111111|11111111|11111101|111          7ffffef  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   316
     "       (254)  |11111111|11111111|11111110|000          7fffff0  [27]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   317
     "       (255)  |11111111|11111111|11111011|10           3ffffee  [26]\n" +
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   318
     "   EOS (256)  |11111111|11111111|11111111|111111      3fffffff  [30]";
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   319
    // @formatter:on
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   320
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   321
    private static final Code EOS = new Code((char) 256, 0x3fffffff, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   322
    private final SortedMap<Character, Code> CODES = readSpecification();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   323
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   324
    private static final class Code {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   325
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   326
        final char sym;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   327
        final int hex;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   328
        final int len;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   329
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   330
        public Code(char sym, int hex, int len) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   331
            this.sym = sym;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   332
            this.hex = hex;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   333
            this.len = len;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   334
        }
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   335
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   336
        @Override
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   337
        public boolean equals(Object o) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   338
            if (this == o) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   339
                return true;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   340
            }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   341
            if (o == null || getClass() != o.getClass()) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   342
                return false;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   343
            }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   344
            Code code = (Code) o;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   345
            return sym == code.sym &&
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   346
                    hex == code.hex &&
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   347
                    len == code.len;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   348
        }
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   349
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   350
        @Override
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   351
        public int hashCode() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   352
            return Objects.hash(sym, hex, len);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   353
        }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   354
    }
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   355
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   356
    private SortedMap<Character, Code> readSpecification() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   357
        Pattern line = Pattern.compile(
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   358
                "\\(\\s*(?<sym>\\d+)\\s*\\)\\s*(?<bits>(\\|([01])+)+)\\s*" +
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   359
                        "(?<hex>[0-9a-zA-Z]+)\\s*\\[\\s*(?<len>\\d+)\\s*\\]");
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   360
        Matcher m = line.matcher(SPECIFICATION);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   361
        SortedMap<Character, Code> map = new TreeMap<>();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   362
        while (m.find()) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   363
            String symString = m.group("sym");
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   364
            String binaryString = m.group("bits").replaceAll("\\|", "");
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   365
            String hexString = m.group("hex");
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   366
            String lenString = m.group("len");
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   367
            // several sanity checks for the data read from the table, just to
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   368
            // make sure what we read makes sense:
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   369
            int sym = Integer.parseInt(symString);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   370
            if (sym < 0 || sym > 65535) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   371
                throw new IllegalArgumentException();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   372
            }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   373
            int binary = Integer.parseInt(binaryString, 2);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   374
            int len = Integer.parseInt(lenString);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   375
            if (binaryString.length() != len) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   376
                throw new IllegalArgumentException();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   377
            }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   378
            int hex = Integer.parseInt(hexString, 16);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   379
            if (hex != binary) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   380
                throw new IllegalArgumentException();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   381
            }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   382
            if (map.put((char) sym, new Code((char) sym, hex, len)) != null) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   383
                // a mapping for sym already exists
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   384
                throw new IllegalStateException();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   385
            }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   386
        }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   387
        if (map.size() != 257) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   388
            throw new IllegalArgumentException();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   389
        }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   390
        return map;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   391
    }
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   392
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   393
    /*
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   394
     * Encodes manually each symbol (character) from the specification and
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   395
     * checks that Huffman.Reader decodes the result back to the initial
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   396
     * character. This verifies that Huffman.Reader is implemented according to
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   397
     * RFC 7541.
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   398
     */
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   399
    @Test
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   400
    public void decodingConsistentWithSpecification() throws IOException {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   401
        Reader reader = READER.get();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   402
        for (Code code : CODES.values()) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   403
            if (code.equals(EOS)) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   404
                continue; // skip EOS
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   405
            }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   406
            ByteBuffer input = encode(code);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   407
            StringBuilder output = new StringBuilder(1);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   408
            reader.read(input, output, true);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   409
            reader.reset();
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   410
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   411
            // compare chars using their decimal representation (as some chars
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   412
            // might not be printable/visible)
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   413
            int expected = code.sym;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   414
            int actual = (int) output.charAt(0);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   415
            assertEquals(output.length(), 1); // exactly 1 character
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   416
            assertEquals(actual, expected);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   417
        }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   418
    }
49944
4690a2871b44 8202423: Small HTTP Client refresh
chegar
parents: 49765
diff changeset
   419
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   420
    @Test
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   421
    public void decodeEOS1() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   422
        Reader reader = READER.get();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   423
        TestHelper.assertVoidThrows(
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   424
                IOException.class,
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   425
                () -> reader.read(encode(EOS), new StringBuilder(), true));
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   426
    }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   427
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   428
    @Test
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   429
    public void decodeEOS2() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   430
        Reader reader = READER.get();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   431
        TestHelper.assertVoidThrows(
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   432
                IOException.class,
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   433
                () -> reader.read(encode(EOS), new StringBuilder(), false));
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   434
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   435
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   436
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   437
    // https://tools.ietf.org/html/rfc7541#appendix-C.4.1
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   438
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   439
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   440
    public void read01() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   441
        readExhaustively("f1e3 c2e5 f23a 6ba0 ab90 f4ff", "www.example.com");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   442
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   443
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   444
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   445
    public void write01() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   446
        writeExhaustively("www.example.com", "f1e3 c2e5 f23a 6ba0 ab90 f4ff");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   447
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   448
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   449
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   450
    // https://tools.ietf.org/html/rfc7541#appendix-C.4.2
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   451
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   452
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   453
    public void read02() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   454
        readExhaustively("a8eb 1064 9cbf", "no-cache");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   455
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   456
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   457
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   458
    public void write02() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   459
        writeExhaustively("no-cache", "a8eb 1064 9cbf");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   460
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   461
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   462
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   463
    // https://tools.ietf.org/html/rfc7541#appendix-C.4.3
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   464
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   465
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   466
    public void read03() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   467
        readExhaustively("25a8 49e9 5ba9 7d7f", "custom-key");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   468
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   469
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   470
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   471
    public void write03() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   472
        writeExhaustively("custom-key", "25a8 49e9 5ba9 7d7f");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   473
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   474
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   475
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   476
    // https://tools.ietf.org/html/rfc7541#appendix-C.4.3
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   477
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   478
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   479
    public void read04() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   480
        readExhaustively("25a8 49e9 5bb8 e8b4 bf", "custom-value");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   481
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   482
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   483
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   484
    public void write04() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   485
        writeExhaustively("custom-value", "25a8 49e9 5bb8 e8b4 bf");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   486
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   487
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   488
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   489
    // https://tools.ietf.org/html/rfc7541#appendix-C.6.1
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   490
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   491
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   492
    public void read05() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   493
        readExhaustively("6402", "302");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   494
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   495
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   496
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   497
    public void write05() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   498
        writeExhaustively("302", "6402");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   499
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   500
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   501
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   502
    // https://tools.ietf.org/html/rfc7541#appendix-C.6.1
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   503
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   504
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   505
    public void read06() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   506
        readExhaustively("aec3 771a 4b", "private");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   507
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   508
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   509
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   510
    public void write06() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   511
        writeExhaustively("private", "aec3 771a 4b");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   512
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   513
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   514
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   515
    // https://tools.ietf.org/html/rfc7541#appendix-C.6.1
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   516
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   517
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   518
    public void read07() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   519
        readExhaustively(
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   520
                "d07a be94 1054 d444 a820 0595 040b 8166 e082 a62d 1bff",
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   521
                "Mon, 21 Oct 2013 20:13:21 GMT");
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   522
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   523
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   524
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   525
    public void write07() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   526
        writeExhaustively(
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   527
                "Mon, 21 Oct 2013 20:13:21 GMT",
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   528
                "d07a be94 1054 d444 a820 0595 040b 8166 e082 a62d 1bff");
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   529
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   530
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   531
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   532
    // https://tools.ietf.org/html/rfc7541#appendix-C.6.1
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   533
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   534
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   535
    public void read08() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   536
        readExhaustively("9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 d3",
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   537
                         "https://www.example.com");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   538
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   539
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   540
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   541
    public void write08() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   542
        writeExhaustively("https://www.example.com",
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   543
                          "9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 d3");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   544
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   545
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   546
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   547
    // https://tools.ietf.org/html/rfc7541#appendix-C.6.2
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   548
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   549
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   550
    public void read09() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   551
        readExhaustively("640e ff", "307");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   552
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   553
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   554
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   555
    public void write09() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   556
        writeExhaustively("307", "640e ff");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   557
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   558
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   559
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   560
    // https://tools.ietf.org/html/rfc7541#appendix-C.6.3
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   561
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   562
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   563
    public void read10() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   564
        readExhaustively(
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   565
                "d07a be94 1054 d444 a820 0595 040b 8166 e084 a62d 1bff",
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   566
                "Mon, 21 Oct 2013 20:13:22 GMT");
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   567
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   568
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   569
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   570
    public void write10() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   571
        writeExhaustively(
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   572
                "Mon, 21 Oct 2013 20:13:22 GMT",
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   573
                "d07a be94 1054 d444 a820 0595 040b 8166 e084 a62d 1bff");
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   574
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   575
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   576
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   577
    // https://tools.ietf.org/html/rfc7541#appendix-C.6.3
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   578
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   579
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   580
    public void read11() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   581
        readExhaustively("9bd9 ab", "gzip");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   582
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   583
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   584
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   585
    public void write11() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   586
        writeExhaustively("gzip", "9bd9 ab");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   587
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   588
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   589
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   590
    // https://tools.ietf.org/html/rfc7541#appendix-C.6.3
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   591
    //
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   592
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   593
    public void read12() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   594
        // The number of possibilities here grow as 2^(n-1). There are 45 bytes
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   595
        // in this input. So it would require 2^44 decoding operations. If we
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   596
        // spend 1 microsecond per operation, it would take approximately
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   597
        //
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   598
        //     ((10^15 * 10^(-6)) / 86400) / 365, or about 32 years
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   599
        //
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   600
        // Conclusion: too big to be read exhaustively
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   601
        read("94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 "
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   602
                     + "d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 "
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   603
                     + "3160 65c0 03ed 4ee5 b106 3d50 07",
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   604
             "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1");
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   605
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   606
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   607
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   608
    public void write12() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   609
        write("foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1",
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   610
              "94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 "
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   611
                      + "d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 "
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   612
                      + "3160 65c0 03ed 4ee5 b106 3d50 07");
49944
4690a2871b44 8202423: Small HTTP Client refresh
chegar
parents: 49765
diff changeset
   613
    }
4690a2871b44 8202423: Small HTTP Client refresh
chegar
parents: 49765
diff changeset
   614
4690a2871b44 8202423: Small HTTP Client refresh
chegar
parents: 49765
diff changeset
   615
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   616
    public void read13() {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   617
        readExhaustively("6274 a6b4 0989 4de4 b27f 80",
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   618
                         "/https2/fixed?0");
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   619
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   620
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   621
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   622
    public void roundTrip() throws IOException {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   623
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   624
        class Helper {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   625
            // Maps code's length to a character that is encoded with a code of
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   626
            // that length. Which of the characters with the same code's length
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   627
            // is picked is undefined.
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   628
            private Map<Integer, Character> chars = new HashMap<>();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   629
            {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   630
                for (Map.Entry<Character, Code> e : CODES.entrySet()) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   631
                    chars.putIfAbsent(e.getValue().len, e.getKey());
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   632
                }
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   633
            }
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   634
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   635
            private CharSequence charsOfLength(int... lengths) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   636
                StringBuilder b = new StringBuilder(lengths.length);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   637
                for (int length : lengths) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   638
                    Character c = chars.get(length);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   639
                    if (c == null) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   640
                        throw new IllegalArgumentException(
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   641
                                "No code has length " + length);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   642
                    }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   643
                    b.append(c);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   644
                }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   645
                return b.toString();
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   646
            }
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   647
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   648
            private void identity(CharSequence str) throws IOException {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   649
                Writer w = WRITER.get();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   650
                StringBuilder b = new StringBuilder(str.length());
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   651
                int size = w.lengthOf(str);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   652
                ByteBuffer buffer = ByteBuffer.allocate(size);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   653
                w.from(str, 0, str.length()).write(buffer);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   654
                Reader r = READER.get();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   655
                r.read(buffer.flip(), b, true);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   656
                assertEquals(b.toString(), str);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   657
            }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   658
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   659
            private void roundTrip(int... lengths) throws IOException {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   660
                identity(charsOfLength(lengths));
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   661
            }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   662
        }
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   663
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   664
        // The idea is to build a number of input strings that are encoded
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   665
        // without the need for padding. The sizes of the encoded forms,
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   666
        // therefore, must be 8, 16, 24, 32, 48, 56, 64 and 72 bits. Then check
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   667
        // that they are encoded and then decoded into the same strings.
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   668
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   669
        Helper h = new Helper();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   670
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   671
        // --  8 bit code --
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   672
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   673
        h.roundTrip( 8);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   674
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   675
        // -- 16 bit code --
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   676
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   677
        h.roundTrip( 5, 11);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   678
        h.roundTrip( 5,  5,  6);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   679
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   680
        // -- 24 bit code --
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   682
        h.roundTrip(24);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   683
        h.roundTrip( 5, 19);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   684
        h.roundTrip( 5,  5, 14);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   685
        h.roundTrip( 5,  5,  6,  8);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   686
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   687
        // -- 32 bit code --
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   688
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   689
        h.roundTrip( 5, 27);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   690
        h.roundTrip( 5,  5, 22);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   691
        h.roundTrip( 5,  5,  7, 15);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   692
        h.roundTrip( 5,  5,  5,  5, 12);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   693
        h.roundTrip( 5,  5,  5,  5,  5,  7);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   694
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   695
        // -- 48 bit code --
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   696
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   697
        h.roundTrip(20, 28);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   698
        h.roundTrip( 5, 13, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   699
        h.roundTrip( 5,  5,  8, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   700
        h.roundTrip( 5,  5,  5,  5, 28);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   701
        h.roundTrip( 5,  5,  5,  5,  5, 23);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   702
        h.roundTrip( 5,  5,  5,  5,  5,  8, 15);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   703
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5, 13);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   704
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5,  8);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   705
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   706
        // -- 56 bit code --
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   707
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   708
        h.roundTrip(26, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   709
        h.roundTrip( 5, 21, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   710
        h.roundTrip( 5,  5, 19, 27);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   711
        h.roundTrip( 5,  5,  5, 11, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   712
        h.roundTrip( 5,  5,  5,  5,  6, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   713
        h.roundTrip( 5,  5,  5,  5,  5,  5, 26);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   714
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5, 21);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   715
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  6, 15);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   716
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5,  5, 11);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   717
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  6);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   718
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   719
        // -- 64 bit code --
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   720
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   721
        h.roundTrip( 6, 28, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   722
        h.roundTrip( 5,  5, 24, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   723
        h.roundTrip( 5,  5,  5, 19, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   724
        h.roundTrip( 5,  5,  5,  5, 14, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   725
        h.roundTrip( 5,  5,  5,  5,  5, 11, 28);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   726
        h.roundTrip( 5,  5,  5,  5,  5,  5,  6, 28);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   727
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5, 24);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   728
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5,  5, 19);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   729
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5,  5,  5, 14);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   730
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  6,  8);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   731
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   732
        // -- 72 bit code --
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   733
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   734
        h.roundTrip(12, 30, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   735
        h.roundTrip( 5,  7, 30, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   736
        h.roundTrip( 5,  5,  5, 27, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   737
        h.roundTrip( 5,  5,  5,  5, 22, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   738
        h.roundTrip( 5,  5,  5,  5,  5, 19, 28);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   739
        h.roundTrip( 5,  5,  5,  5,  5,  5, 12, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   740
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  7, 30);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   741
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5,  5, 27);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   742
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5,  5,  5, 22);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   743
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  7, 15);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   744
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5, 12);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   745
        h.roundTrip( 5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  7);
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   746
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   747
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   748
    @Test
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   749
    public void cannotEncodeOutsideByte() {
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   750
        TestHelper.Block<Object> coding =
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   751
                () -> WRITER.get()
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   752
                        .from(String.valueOf((char) 256), 0, 1)
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   753
                        .write(ByteBuffer.allocate(1));
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   754
        RuntimeException e =
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   755
                TestHelper.assertVoidThrows(RuntimeException.class, coding);
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   756
        TestHelper.assertExceptionMessageContains(e, "char");
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   757
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   758
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   759
    private static void read(String hexdump, String decoded) {
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   760
        ByteBuffer source = SpecHelper.toBytes(hexdump);
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   761
        Appendable actual = new StringBuilder();
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   762
        Reader reader = READER.get();
48083
b1c1b4ef4be2 8191494: Refresh incubating HTTP Client
chegar
parents: 47216
diff changeset
   763
        try {
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   764
            reader.read(source, actual, true);
48083
b1c1b4ef4be2 8191494: Refresh incubating HTTP Client
chegar
parents: 47216
diff changeset
   765
        } catch (IOException e) {
b1c1b4ef4be2 8191494: Refresh incubating HTTP Client
chegar
parents: 47216
diff changeset
   766
            throw new UncheckedIOException(e);
b1c1b4ef4be2 8191494: Refresh incubating HTTP Client
chegar
parents: 47216
diff changeset
   767
        }
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   768
        assertEquals(actual.toString(), decoded);
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   769
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   770
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   771
    private static void readExhaustively(String hexdump, String decoded) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   772
        ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate(0);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   773
        Reader reader = READER.get();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   774
        ByteBuffer source = SpecHelper.toBytes(hexdump);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   775
        StringBuilder actual = new StringBuilder();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   776
        BuffersTestingKit.forEachSplit(source, buffers -> {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   777
            try {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   778
                for (ByteBuffer b : buffers) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   779
                    reader.read(b, actual, false);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   780
                }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   781
                reader.read(EMPTY_BUFFER, actual, true);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   782
            } catch (IOException e) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   783
                throw new UncheckedIOException(e);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   784
            }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   785
            assertEquals(actual.toString(), decoded);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   786
            reader.reset();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   787
            actual.setLength(0);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   788
        });
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   789
    }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   790
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   791
    private static void write(String decoded, String hexdump) {
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   792
        Writer writer = WRITER.get();
49944
4690a2871b44 8202423: Small HTTP Client refresh
chegar
parents: 49765
diff changeset
   793
        int n = writer.lengthOf(decoded);
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   794
        ByteBuffer destination = ByteBuffer.allocateDirect(n);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   795
        writer.from(decoded, 0, decoded.length());
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   796
        boolean written = writer.write(destination);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   797
        assertTrue(written);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   798
        String actual = SpecHelper.toHexdump(destination.flip());
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   799
        assertEquals(actual, hexdump);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   800
        writer.reset();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   801
    }
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   802
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   803
    private static void writeExhaustively(String decoded, String hexdump) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   804
        Writer writer = WRITER.get();
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   805
        int n = writer.lengthOf(decoded);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   806
        ByteBuffer destination = ByteBuffer.allocate(n);
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   807
        BuffersTestingKit.forEachSplit(destination, byteBuffers -> {
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   808
            writer.from(decoded, 0, decoded.length());
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   809
            boolean written = false;
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   810
            for (ByteBuffer b : byteBuffers) {
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   811
                int pos = b.position();
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   812
                written = writer.write(b);
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   813
                b.position(pos); // "flip" to the saved position, for reading
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   814
            }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   815
            assertTrue(written);
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   816
            ByteBuffer concated = BuffersTestingKit.concat(byteBuffers);
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   817
            String actual = SpecHelper.toHexdump(concated);
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   818
            assertEquals(actual, hexdump);
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   819
            writer.reset();
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   820
        });
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   821
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   822
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   823
    /*
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   824
     * Encodes a single character. This representation is padded, thus ready to
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   825
     * be decoded.
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   826
     */
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   827
    private static ByteBuffer encode(Code code) {
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   828
        int EOS_MSB = EOS.hex << (32 - EOS.len);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   829
        int padding = EOS_MSB >>> code.len;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   830
        int hexMSB = code.hex << (32 - code.len);
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   831
        int c = hexMSB | padding;
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   832
        int n = bytesForBits(code.len);
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   833
        byte[] result = new byte[n];
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   834
        for (int i = 0; i < n; i++) {
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   835
            result[i] = (byte) (c >> (32 - 8 * (i + 1)));
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   836
        }
50681
4254bed3c09d 8204679: HTTP Client refresh
chegar
parents: 49944
diff changeset
   837
        return ByteBuffer.wrap(result);
42460
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   838
    }
7133f144981a 8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
diff changeset
   839
}