Interface Net.HttpResponse

  • Enclosing interface:
    Net

    public static interface Net.HttpResponse
    HTTP response interface with methods to get the response data as a byte[], a String or an InputStream.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String getHeader​(java.lang.String name)
      Returns the value of the header with the given name as a String, or null if the header is not set.
      java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getHeaders()
      Returns a Map of the headers.
      byte[] getResult()
      Returns the data of the HTTP response as a byte[].
      java.io.InputStream getResultAsStream()
      Returns the data of the HTTP response as an InputStream.
      java.lang.String getResultAsString()
      Returns the data of the HTTP response as a String.
      HttpStatus getStatus()
      Returns the HttpStatus containing the statusCode of the HTTP response.
    • Method Detail

      • getResult

        byte[] getResult()
        Returns the data of the HTTP response as a byte[].

        Note: This method may only be called once per response.

        Returns:
        the result as a byte[] or null in case of a timeout or if the operation was canceled/terminated abnormally. The timeout is specified when creating the HTTP request, with Net.HttpRequest.setTimeOut(int)
      • getResultAsString

        java.lang.String getResultAsString()
        Returns the data of the HTTP response as a String.

        Note: This method may only be called once per response.

        Returns:
        the result as a string or null in case of a timeout or if the operation was canceled/terminated abnormally. The timeout is specified when creating the HTTP request, with Net.HttpRequest.setTimeOut(int)
      • getResultAsStream

        java.io.InputStream getResultAsStream()
        Returns the data of the HTTP response as an InputStream.
        Warning:
        Do not store a reference to this InputStream outside of Net.HttpResponseListener.handleHttpResponse(HttpResponse). The underlying HTTP connection will be closed after that callback finishes executing. Reading from the InputStream after it's connection has been closed will lead to exception.
        Returns:
        An InputStream with the Net.HttpResponse data.
      • getStatus

        HttpStatus getStatus()
        Returns the HttpStatus containing the statusCode of the HTTP response.
      • getHeader

        java.lang.String getHeader​(java.lang.String name)
        Returns the value of the header with the given name as a String, or null if the header is not set. See HttpResponseHeader.
      • getHeaders

        java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getHeaders()
        Returns a Map of the headers. The keys are Strings that represent the header name. Each values is a List of Strings that represent the corresponding header values. See HttpResponseHeader.