Class HttpResponse

java.lang.Object
net.dreamlu.mica.http.HttpResponse
All Implemented Interfaces:
Closeable, AutoCloseable, ResponseSpec

public class HttpResponse extends Object implements ResponseSpec, Closeable
ok http 封装,相应结构体
Author:
L.cm
  • Method Details

    • code

      public int code()
      Description copied from interface: ResponseSpec
      Returns the HTTP code.
      Specified by:
      code in interface ResponseSpec
      Returns:
      code
    • message

      public String message()
      Description copied from interface: ResponseSpec
      Returns the HTTP status message.
      Specified by:
      message in interface ResponseSpec
      Returns:
      message
    • isOk

      public boolean isOk()
      Description copied from interface: ResponseSpec
      Returns the HTTP isSuccessful.
      Specified by:
      isOk in interface ResponseSpec
      Returns:
      boolean
    • isRedirect

      public boolean isRedirect()
      Description copied from interface: ResponseSpec
      Returns the is Redirect.
      Specified by:
      isRedirect in interface ResponseSpec
      Returns:
      is Redirect
    • headers

      public okhttp3.Headers headers()
      Description copied from interface: ResponseSpec
      Returns the Headers.
      Specified by:
      headers in interface ResponseSpec
      Returns:
      Headers
    • cookies

      public List<okhttp3.Cookie> cookies()
      Description copied from interface: ResponseSpec
      Returns the Cookies.
      Specified by:
      cookies in interface ResponseSpec
      Returns:
      Cookie List
    • rawRequest

      public okhttp3.Request rawRequest()
      Description copied from interface: ResponseSpec
      Returns rawRequest.
      Specified by:
      rawRequest in interface ResponseSpec
      Returns:
      Request
    • rawResponse

      public okhttp3.Response rawResponse()
      Description copied from interface: ResponseSpec
      Returns rawResponse.
      Specified by:
      rawResponse in interface ResponseSpec
      Returns:
      Response
    • rawBody

      public okhttp3.ResponseBody rawBody()
      Description copied from interface: ResponseSpec
      Returns rawBody.
      Specified by:
      rawBody in interface ResponseSpec
      Returns:
      ResponseBody
    • asString

      public String asString()
      Description copied from interface: ResponseSpec
      Returns body String.
      Specified by:
      asString in interface ResponseSpec
      Returns:
      body String
    • asString

      public String asString(Charset charset)
      Description copied from interface: ResponseSpec
      Returns body String.
      Specified by:
      asString in interface ResponseSpec
      Parameters:
      charset - Charset
      Returns:
      body String
    • asBytes

      public byte[] asBytes()
      Description copied from interface: ResponseSpec
      Returns body to byte arrays.
      Specified by:
      asBytes in interface ResponseSpec
      Returns:
      byte arrays
    • asStream

      public InputStream asStream()
      Description copied from interface: ResponseSpec
      Returns body to InputStream.
      Specified by:
      asStream in interface ResponseSpec
      Returns:
      InputStream
    • asJsonNode

      public com.fasterxml.jackson.databind.JsonNode asJsonNode()
      Description copied from interface: ResponseSpec
      Returns body to JsonNode.
      Specified by:
      asJsonNode in interface ResponseSpec
      Returns:
      JsonNode
    • asValue

      public <T> T asValue(Class<T> valueType)
      Description copied from interface: ResponseSpec
      Returns body to Object.
      Specified by:
      asValue in interface ResponseSpec
      Parameters:
      valueType - value value type
      Returns:
      Object
    • asValue

      public <T> T asValue(com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
      Description copied from interface: ResponseSpec
      Returns body to Object.
      Specified by:
      asValue in interface ResponseSpec
      Parameters:
      typeReference - value Type Reference
      Returns:
      Object
    • asList

      public <T> List<T> asList(Class<T> valueType)
      Description copied from interface: ResponseSpec
      Returns body to List.
      Specified by:
      asList in interface ResponseSpec
      Parameters:
      valueType - value type
      Returns:
      List
    • asMap

      public <K, V> Map<K,V> asMap(Class<?> keyClass, Class<?> valueType)
      Description copied from interface: ResponseSpec
      Returns body to Map.
      Specified by:
      asMap in interface ResponseSpec
      Parameters:
      keyClass - key type
      valueType - value type
      Returns:
      Map
    • asMap

      public <V> Map<String,V> asMap(Class<?> valueType)
      Description copied from interface: ResponseSpec
      Returns body to Map.
      Specified by:
      asMap in interface ResponseSpec
      Parameters:
      valueType - value 类型
      Returns:
      Map
    • toFile

      public File toFile(File file)
      Description copied from interface: ResponseSpec
      toFile.
      Specified by:
      toFile in interface ResponseSpec
      Parameters:
      file - File
      Returns:
      File
    • toFile

      public Path toFile(Path path)
      Description copied from interface: ResponseSpec
      toFile.
      Specified by:
      toFile in interface ResponseSpec
      Parameters:
      path - Path
      Returns:
      Path
    • contentType

      public okhttp3.MediaType contentType()
      Description copied from interface: ResponseSpec
      Returns contentType.
      Specified by:
      contentType in interface ResponseSpec
      Returns:
      contentType
    • contentLength

      public long contentLength()
      Description copied from interface: ResponseSpec
      Returns contentLength.
      Specified by:
      contentLength in interface ResponseSpec
      Returns:
      contentLength
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException