Class Helpers


  • public final class Helpers
    extends java.lang.Object
    Public helper methods for use by customers and end-users.
    • Constructor Summary

      Constructors 
      Constructor Description
      Helpers()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.net.http.HttpRequest.Builder copy​(java.net.http.HttpRequest request)
      Returns an HttpRequest.Builder which is initialized with the state of the given HttpRequest.
      static java.net.http.HttpRequest.Builder copy​(java.net.http.HttpRequest request, java.util.function.BiPredicate<java.lang.String,​java.lang.String> filter)
      Returns an HttpRequest.Builder which is initialized with the state of the given HttpRequest.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Helpers

        public Helpers()
    • Method Detail

      • copy

        public static java.net.http.HttpRequest.Builder copy​(java.net.http.HttpRequest request)
        Returns an HttpRequest.Builder which is initialized with the state of the given HttpRequest.

        Note that headers can be added and modified but not removed. To remove headers use copy(HttpRequest, BiPredicate) (which applies a filter to the headers while copying).

        Note also that this method is redundant from JDK 16 because the method HttpRequest.newBuilder(HttpRequest) is available.

        Parameters:
        request - request to copy
        Returns:
        a builder initialized with values from request
      • copy

        public static java.net.http.HttpRequest.Builder copy​(java.net.http.HttpRequest request,
                                                             java.util.function.BiPredicate<java.lang.String,​java.lang.String> filter)
        Returns an HttpRequest.Builder which is initialized with the state of the given HttpRequest.

        Note that this method is redundant from JDK 16 because the method HttpRequest.newBuilder(HttpRequest, BiPredicate) is available.

        Parameters:
        request - request to copy
        filter - selects which header key-values to include in the copied request
        Returns:
        a builder initialized with values from request