Interface HttpResponse

    • Method Detail

      • httpResponse

        static HttpResponse httpResponse​(java.lang.String response)
        This is a helper method to create a new instance of HttpResponse.
        Parameters:
        response - The HTTP response.
        Returns:
        A new HttpResponse instance.
      • httpResponse

        static HttpResponse httpResponse​(java.util.List<java.lang.String> headers,
                                         ByteArray body)
        This is a helper method to create a new instance of HttpResponse.
        Parameters:
        headers - A list of HTTP headers.
        body - An HTTP response body.
        Returns:
        A new HttpResponse instance.
      • httpResponse

        static HttpResponse httpResponse​(java.util.List<java.lang.String> headers,
                                         java.lang.String body)
        This is a helper method to create a new instance of HttpResponse.
        Parameters:
        headers - A list of HTTP headers.
        body - An HTTP response body.
        Returns:
        A new HttpResponse instance.
      • statusCode

        short statusCode()
        This method is used to obtain the HTTP status code contained in the response.
        Returns:
        HTTP status code.
      • cookies

        java.util.List<Cookie> cookies()
        This method is used to obtain details of the HTTP cookies set in the response.
        Returns:
        A list of Cookie objects representing the cookies set in the response, if any.
      • statedMimeType

        MimeType statedMimeType()
        This method is used to obtain the MIME type of the response, as stated in the HTTP headers.
        Returns:
        The stated MIME type.
      • inferredMimeType

        MimeType inferredMimeType()
        This method is used to obtain the MIME type of the response, as inferred from the contents of the HTTP message body.
        Returns:
        The inferred MIME type.
      • keywordCounts

        java.util.List<KeywordCount> keywordCounts​(java.lang.String... keywords)
        This method is used to retrieve the number of types given keywords appear in the response.
        Parameters:
        keywords - Keywords to count.
        Returns:
        List of keyword counts in the order they were provided.
      • attributes

        java.util.List<Attribute> attributes​(AttributeType... types)
        This method is used to retrieve the values of response attributes.
        Parameters:
        types - Response attributes to retrieve values for.
        Returns:
        List of Attribute objects.
      • withBody

        HttpResponse withBody​(java.lang.String body)
        This is a helper method that builds a modified response with the updated body. Updates Content-Length header.
        Parameters:
        body - the new body for the response
        Returns:
        A new HttpResponse instance.
      • withBody

        HttpResponse withBody​(ByteArray body)
        This is a helper method that builds a modified response with the updated body. Updates Content-Length header.
        Parameters:
        body - the new body for the response
        Returns:
        A new HttpResponse instance.
      • addHeader

        HttpResponse addHeader​(HttpHeader header)
        Adds an HTTP header to the response.
        Parameters:
        header - The HttpHeader to add to the response.
        Returns:
        The updated response containing the added header.
      • addHeader

        HttpResponse addHeader​(java.lang.String name,
                               java.lang.String value)
        Adds an HTTP header to the response.
        Parameters:
        name - The name of the header.
        value - The value of the header.
        Returns:
        The updated response containing the added header.
      • updateHeader

        HttpResponse updateHeader​(HttpHeader header)
        Updates an existing HTTP header in the response with a new value.
        Parameters:
        header - The HttpHeader to update containing the new value.
        Returns:
        The updated response containing the updated header.
      • updateHeader

        HttpResponse updateHeader​(java.lang.String name,
                                  java.lang.String value)
        Updates an existing HTTP header in the response with a new value.
        Parameters:
        name - The name of the header to update the value of.
        value - The new value of the specified HTTP header.
        Returns:
        The updated response containing the updated header.
      • removeHeader

        HttpResponse removeHeader​(HttpHeader header)
        Removes an existing HTTP header from the current response.
        Parameters:
        header - The HttpHeader to remove from the response.
        Returns:
        The updated response containing the removed header.
      • removeHeader

        HttpResponse removeHeader​(java.lang.String name)
        Removes an existing HTTP header from the current response.
        Parameters:
        name - The name of the HTTP header to remove from the response.
        Returns:
        The updated response containing the removed header.