Class ServerResponse

    • Constructor Detail

      • ServerResponse

        public ServerResponse​(org.asynchttpclient.Response response)
    • Method Detail

      • wrap

        public static ServerResponse wrap​(org.asynchttpclient.Response response)
      • getResponseBody

        public java.lang.String getResponseBody​(java.nio.charset.Charset charset)
      • getResponseBody

        public java.lang.String getResponseBody()
      • getResponseBodyAsBytes

        public byte[] getResponseBodyAsBytes()
      • getResponseBodyAsStream

        public java.io.InputStream getResponseBodyAsStream()
      • getHeaders

        public java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getHeaders()
        Description copied from interface: ServerResponseHeaders
        Returns all response headers
        Specified by:
        getHeaders in interface ServerResponseHeaders
        Returns:
        all response headers
      • hasResponseHeaders

        public boolean hasResponseHeaders()
      • hasResponseStatus

        public boolean hasResponseStatus()
      • getCookies

        public java.util.List<io.netty.handler.codec.http.cookie.Cookie> getCookies()
      • isRedirected

        public boolean isRedirected()
      • getResponseBodyAsByteBuffer

        public java.nio.ByteBuffer getResponseBodyAsByteBuffer()
      • getContentType

        public java.util.Optional<java.lang.String> getContentType()
        Description copied from interface: ServerResponseHeaders
        Returns some Content-Type if present in response header, None otherwise
        Specified by:
        getContentType in interface ServerResponseHeaders
        Returns:
        some Content-Type if present in response header, None otherwise
      • getHeaders

        public java.util.List<java.lang.String> getHeaders​(java.lang.String name)
        Description copied from interface: ServerResponseHeaders
        Returns the HTTP Response header values for the specified header name.
        Specified by:
        getHeaders in interface ServerResponseHeaders
        Parameters:
        name - the header name
        Returns:
        the HTTP Response header values for the specified header name.
      • hasResponseBody

        public boolean hasResponseBody()
      • getUri

        public org.asynchttpclient.uri.Uri getUri()
      • getResponseBodyExcerpt

        public java.lang.String getResponseBodyExcerpt​(int maxLength)
      • getResponseBodyExcerpt

        public java.lang.String getResponseBodyExcerpt​(int maxLength,
                                                       java.lang.String charset)
      • getHeader

        public java.util.Optional<java.lang.String> getHeader​(java.lang.String name)
        Description copied from interface: ServerResponseHeaders
        Returns some value for the specified header name, or None if not present in the response headers.
        Specified by:
        getHeader in interface ServerResponseHeaders
        Parameters:
        name - header name to look up.
        Returns:
        some value for the specified header name, or None if not present in the response headers.
      • match

        public <T> T match​(java.util.function.Function<ServerResponseStatus,​T> matchStatus,
                           java.util.function.Function<ServerResponseHeaders,​T> matchHeaders,
                           java.util.function.Function<ServerResponseBodyPart,​T> matchBodyPart,
                           java.util.function.Function<ServerResponse,​T> matchServerResponse)
        Description copied from interface: ServerResponseStatus
        Apply a function on this instance, depending on its type.

        This uses a condensed form of the Visitor pattern.

        Specified by:
        match in interface ServerResponseBodyPart
        Specified by:
        match in interface ServerResponseElement
        Specified by:
        match in interface ServerResponseHeaders
        Specified by:
        match in interface ServerResponseStatus
        Type Parameters:
        T - the return type of all matcher functions
        Parameters:
        matchStatus - the function to invoke when this instance is a ServerResponseStatus
        matchHeaders - the function to invoke when this instance is a ServerResponseHeaders
        matchBodyPart - the function to invoke when this instance is a ServerResponseBodyPart
        matchServerResponse - the function to invoke when this instance is a ServerResponse
        Returns:
        the result of the matcher function that matches this instance type