Class MockLowLevelHttpResponse

    • Constructor Detail

      • MockLowLevelHttpResponse

        public MockLowLevelHttpResponse()
    • Method Detail

      • setContent

        public MockLowLevelHttpResponse setContent(String stringContent)
        Sets the response content to the given content string.

        If the input string is null, it will set the content to null. Else, it will use TestableByteArrayInputStream with the UTF-8 encoded string content.

        Parameters:
        stringContent - content string or null for none
      • setZeroContent

        public MockLowLevelHttpResponse setZeroContent()
        Sets the content to null and the content length to 0. Note that the result will have a content length header whose value is 0.
        Since:
        1.18
      • getContentEncoding

        public String getContentEncoding()
        Description copied from class: LowLevelHttpResponse
        Returns the content encoding (for example "gzip") or null for none.
      • getContentLength

        public long getContentLength()
        Description copied from class: LowLevelHttpResponse
        Returns the content length or 0 for none.
      • getContentType

        public final String getContentType()
        Description copied from class: LowLevelHttpResponse
        Returns the content type or null for none.
      • getHeaderCount

        public int getHeaderCount()
        Description copied from class: LowLevelHttpResponse
        Returns the number of HTTP response headers.

        Note that multiple headers of the same name need to be supported, in which case each header value is treated as a separate header.

      • getHeaderName

        public String getHeaderName(int index)
        Description copied from class: LowLevelHttpResponse
        Returns the HTTP response header name at the given zero-based index.
      • getHeaderValue

        public String getHeaderValue(int index)
        Description copied from class: LowLevelHttpResponse
        Returns the HTTP response header value at the given zero-based index.
      • getReasonPhrase

        public String getReasonPhrase()
        Description copied from class: LowLevelHttpResponse
        Returns the HTTP reason phrase or null for none.
      • getStatusCode

        public int getStatusCode()
        Description copied from class: LowLevelHttpResponse
        Returns the response status code or <=0 for none.
      • getStatusLine

        public String getStatusLine()
        Description copied from class: LowLevelHttpResponse
        Returns the response status line or null for none.
      • getHeaderNames

        public final List<String> getHeaderNames()
        Returns the list of header names of HTTP response.
        Since:
        1.5
      • setHeaderNames

        public MockLowLevelHttpResponse setHeaderNames(List<String> headerNames)
        Sets the list of header names of HTTP response.

        Default value is an empty list.

        Since:
        1.5
      • getHeaderValues

        public final List<String> getHeaderValues()
        Returns the list of header values of HTTP response.

        Default value is an empty list.

        Since:
        1.5
      • setContentType

        public MockLowLevelHttpResponse setContentType(String contentType)
        Sets the content type of HTTP response or null for none.
        Since:
        1.5
      • setContentEncoding

        public MockLowLevelHttpResponse setContentEncoding(String contentEncoding)
        Sets the content encoding or null for none.
        Since:
        1.5
      • setContentLength

        public MockLowLevelHttpResponse setContentLength(long contentLength)
        Sets the content length or -1 for unknown.

        By default it is -1.

        Since:
        1.5
      • setStatusCode

        public MockLowLevelHttpResponse setStatusCode(int statusCode)
        Sets the status code of HTTP response.

        Default value is 200.

        Since:
        1.5
      • disconnect

        public void disconnect()
                        throws IOException
        Description copied from class: LowLevelHttpResponse
        Default implementation does nothing, but subclasses may override to attempt to abort the connection or release allocated system resources for this connection.
        Overrides:
        disconnect in class  LowLevelHttpResponse
        Throws:
        IOException - I/O exception
      • isDisconnected

        public boolean isDisconnected()
        Returns whether disconnect() has been called.
        Since:
        1.14