Class SafeHttpHelper

  • All Implemented Interfaces:

    
    public class SafeHttpHelper
    
                        
    Since:

    2022-11-29

    Author:

    trydofor

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      SafeHttpHelper()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static boolean isSafeRedirect(@NotNull() String uri, Set<String> hosts) Whether the host of uri is in the `hosts`, case-sensitive
      static String parseHostPort(String uri)
      Only parse http/https, get host and port
      
      rfc3986
      
      The authority component is preceded by a double slash ("//") and is
      terminated by the next slash ("/"), question mark ("?"), or number
      sign ("#") character, or by the end of the URI.
      
      [ userinfo "@" ] host [ ":" port ]
      host = IP-literal / IPv4address / IPv6address / reg-name
      //[107:0:0:0:200:7051]:80
      
      • Methods inherited from class java.lang.Object

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

      • SafeHttpHelper

        SafeHttpHelper()
    • Method Detail

      • isSafeRedirect

         static boolean isSafeRedirect(@NotNull() String uri, Set<String> hosts)

        Whether the host of uri is in the `hosts`, case-sensitive

      • parseHostPort

         static String parseHostPort(String uri)
        Only parse http/https, get host and port
        
        rfc3986
        
        The authority component is preceded by a double slash ("//") and is
        terminated by the next slash ("/"), question mark ("?"), or number
        sign ("#") character, or by the end of the URI.
        
        [ userinfo "@" ] host [ ":" port ]
        host = IP-literal / IPv4address / IPv6address / reg-name
        //[107:0:0:0:200:7051]:80