java.lang.Object
io.getlime.security.powerauth.lib.cmd.util.HttpUtil

public class HttpUtil
extends java.lang.Object
Simple HTTP utilities class.
Author:
Petr Dvorak, petr@wultra.com
  • Constructor Summary

    Constructors
    Constructor Description
    HttpUtil()  
  • Method Summary

    Modifier and Type Method Description
    static java.util.Map<java.lang.String,​java.lang.String> flattenHttpHeaders​(org.springframework.http.HttpHeaders headers)
    Flattens headers to a simple map of header names to first header value for a given name
    static <T> T fromBytes​(byte[] data, java.lang.Class<T> cls)
    Deserializes an object entity from byte array representation of a json
    static byte[] toRequestBytes​(java.lang.Object objectValue)
    Serializes an object value for request sending as byte array representation

    Methods inherited from class java.lang.Object

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

    • HttpUtil

      public HttpUtil()
  • Method Details

    • flattenHttpHeaders

      public static java.util.Map<java.lang.String,​java.lang.String> flattenHttpHeaders​(org.springframework.http.HttpHeaders headers)
      Flattens headers to a simple map of header names to first header value for a given name
      Parameters:
      headers - HTTP headers
      Returns:
      Headers as a map of header names to first header value for a given name
    • toRequestBytes

      public static byte[] toRequestBytes​(@Nullable java.lang.Object objectValue) throws com.fasterxml.jackson.core.JsonProcessingException
      Serializes an object value for request sending as byte array representation
      Parameters:
      objectValue - Object value
      Returns:
      byte array representing the object value
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - when an error during serialization to JSON occurred
    • fromBytes

      public static <T> T fromBytes​(byte[] data, java.lang.Class<T> cls) throws java.io.IOException
      Deserializes an object entity from byte array representation of a json
      Type Parameters:
      T - Type of the deserialized object
      Parameters:
      data - Byte array representation of json
      cls - Class
      Returns:
      Object entity
      Throws:
      java.io.IOException - when an error during deserialization from JSON occurred