src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/DecodingCallback.java
branchhttp-client-branch
changeset 55763 634d8e14c172
parent 47216 71c04702a3d5
child 56088 38fac6d0521d
equal deleted inserted replaced
55762:e947a3a50a95 55763:634d8e14c172
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    33  * <p> Methods of the callback are never called by a decoder with any of the
    33  * <p> Methods of the callback are never called by a decoder with any of the
    34  * arguments being {@code null}.
    34  * arguments being {@code null}.
    35  *
    35  *
    36  * @apiNote
    36  * @apiNote
    37  *
    37  *
    38  * <p> The callback provides methods for all possible <a
    38  * <p> The callback provides methods for all possible
    39  * href="https://tools.ietf.org/html/rfc7541#section-6">binary
    39  * <a href="https://tools.ietf.org/html/rfc7541#section-6">binary representations</a>.
    40  * representations</a>. This could be useful for implementing an intermediary,
    40  * This could be useful for implementing an intermediary, logging, debugging,
    41  * logging, debugging, etc.
    41  * etc.
    42  *
    42  *
    43  * <p> The callback is an interface in order to interoperate with lambdas (in
    43  * <p> The callback is an interface in order to interoperate with lambdas (in
    44  * the most common use case):
    44  * the most common use case):
    45  * <pre>{@code
    45  * <pre>{@code
    46  *     DecodingCallback callback = (name, value) -> System.out.println(name + ", " + value);
    46  *     DecodingCallback callback = (name, value) -> System.out.println(name + ", " + value);
    96      *         whether or not the value is sensitive
    96      *         whether or not the value is sensitive
    97      *
    97      *
    98      * @see #onLiteralNeverIndexed(int, CharSequence, CharSequence, boolean)
    98      * @see #onLiteralNeverIndexed(int, CharSequence, CharSequence, boolean)
    99      * @see #onLiteralNeverIndexed(CharSequence, boolean, CharSequence, boolean)
    99      * @see #onLiteralNeverIndexed(CharSequence, boolean, CharSequence, boolean)
   100      */
   100      */
   101     default void onDecoded(CharSequence name, CharSequence value,
   101     default void onDecoded(CharSequence name,
       
   102                            CharSequence value,
   102                            boolean sensitive) {
   103                            boolean sensitive) {
   103         onDecoded(name, value);
   104         onDecoded(name, value);
   104     }
   105     }
   105 
   106 
   106     /**
   107     /**
   140      * @param value
   141      * @param value
   141      *         header value
   142      *         header value
   142      * @param valueHuffman
   143      * @param valueHuffman
   143      *         if the {@code value} was Huffman encoded
   144      *         if the {@code value} was Huffman encoded
   144      */
   145      */
   145     default void onLiteral(int index, CharSequence name,
   146     default void onLiteral(int index,
   146                            CharSequence value, boolean valueHuffman) {
   147                            CharSequence name,
       
   148                            CharSequence value,
       
   149                            boolean valueHuffman) {
   147         onDecoded(name, value, false);
   150         onDecoded(name, value, false);
   148     }
   151     }
   149 
   152 
   150     /**
   153     /**
   151      * A <a href="https://tools.ietf.org/html/rfc7541#section-6.2.2">Literal
   154      * A <a href="https://tools.ietf.org/html/rfc7541#section-6.2.2">Literal
   164      * @param value
   167      * @param value
   165      *         header value
   168      *         header value
   166      * @param valueHuffman
   169      * @param valueHuffman
   167      *         if the {@code value} was Huffman encoded
   170      *         if the {@code value} was Huffman encoded
   168      */
   171      */
   169     default void onLiteral(CharSequence name, boolean nameHuffman,
   172     default void onLiteral(CharSequence name,
   170                            CharSequence value, boolean valueHuffman) {
   173                            boolean nameHuffman,
       
   174                            CharSequence value,
       
   175                            boolean valueHuffman) {
   171         onDecoded(name, value, false);
   176         onDecoded(name, value, false);
   172     }
   177     }
   173 
   178 
   174     /**
   179     /**
   175      * A <a href="https://tools.ietf.org/html/rfc7541#section-6.2.3">Literal
   180      * A <a href="https://tools.ietf.org/html/rfc7541#section-6.2.3">Literal
   188      * @param value
   193      * @param value
   189      *         header value
   194      *         header value
   190      * @param valueHuffman
   195      * @param valueHuffman
   191      *         if the {@code value} was Huffman encoded
   196      *         if the {@code value} was Huffman encoded
   192      */
   197      */
   193     default void onLiteralNeverIndexed(int index, CharSequence name,
   198     default void onLiteralNeverIndexed(int index,
       
   199                                        CharSequence name,
   194                                        CharSequence value,
   200                                        CharSequence value,
   195                                        boolean valueHuffman) {
   201                                        boolean valueHuffman) {
   196         onDecoded(name, value, true);
   202         onDecoded(name, value, true);
   197     }
   203     }
   198 
   204 
   213      * @param value
   219      * @param value
   214      *         header value
   220      *         header value
   215      * @param valueHuffman
   221      * @param valueHuffman
   216      *         if the {@code value} was Huffman encoded
   222      *         if the {@code value} was Huffman encoded
   217      */
   223      */
   218     default void onLiteralNeverIndexed(CharSequence name, boolean nameHuffman,
   224     default void onLiteralNeverIndexed(CharSequence name,
   219                                        CharSequence value, boolean valueHuffman) {
   225                                        boolean nameHuffman,
       
   226                                        CharSequence value,
       
   227                                        boolean valueHuffman) {
   220         onDecoded(name, value, true);
   228         onDecoded(name, value, true);
   221     }
   229     }
   222 
   230 
   223     /**
   231     /**
   224      * A <a href="https://tools.ietf.org/html/rfc7541#section-6.2.1">Literal
   232      * A <a href="https://tools.ietf.org/html/rfc7541#section-6.2.1">Literal
   239      * @param valueHuffman
   247      * @param valueHuffman
   240      *         if the {@code value} was Huffman encoded
   248      *         if the {@code value} was Huffman encoded
   241      */
   249      */
   242     default void onLiteralWithIndexing(int index,
   250     default void onLiteralWithIndexing(int index,
   243                                        CharSequence name,
   251                                        CharSequence name,
   244                                        CharSequence value, boolean valueHuffman) {
   252                                        CharSequence value,
       
   253                                        boolean valueHuffman) {
   245         onDecoded(name, value, false);
   254         onDecoded(name, value, false);
   246     }
   255     }
   247 
   256 
   248     /**
   257     /**
   249      * A <a href="https://tools.ietf.org/html/rfc7541#section-6.2.1">Literal
   258      * A <a href="https://tools.ietf.org/html/rfc7541#section-6.2.1">Literal
   262      * @param value
   271      * @param value
   263      *         header value
   272      *         header value
   264      * @param valueHuffman
   273      * @param valueHuffman
   265      *         if the {@code value} was Huffman encoded
   274      *         if the {@code value} was Huffman encoded
   266      */
   275      */
   267     default void onLiteralWithIndexing(CharSequence name, boolean nameHuffman,
   276     default void onLiteralWithIndexing(CharSequence name,
   268                                        CharSequence value, boolean valueHuffman) {
   277                                        boolean nameHuffman,
       
   278                                        CharSequence value,
       
   279                                        boolean valueHuffman) {
   269         onDecoded(name, value, false);
   280         onDecoded(name, value, false);
   270     }
   281     }
   271 
   282 
   272     /**
   283     /**
   273      * A <a href="https://tools.ietf.org/html/rfc7541#section-6.3">Dynamic Table
   284      * A <a href="https://tools.ietf.org/html/rfc7541#section-6.3">Dynamic Table