Class HttpMessage

    • Constructor Detail

      • HttpMessage

        public HttpMessage()
        Empty constructor initializing with empty message payload.
      • HttpMessage

        public HttpMessage​(Message message)
        Constructs copy of given message.
        Parameters:
        message - The base message for the copy operation
      • HttpMessage

        public HttpMessage​(Object payload)
        Default message using message payload.
        Parameters:
        payload - The payload for the message to set
      • HttpMessage

        public HttpMessage​(Object payload,
                           Map<String,​Object> headers)
        Default message using message payload and headers.
        Parameters:
        payload - The payload for the message to set
        headers - A key value map containing the headers to set
    • Method Detail

      • method

        public HttpMessage method​(org.springframework.http.HttpMethod method)
        Sets the Http request method header.
        Parameters:
        method - The Http method header to use
        Returns:
        The altered HttpMessage
      • version

        public HttpMessage version​(String version)
        Sets the Http version header.
        Parameters:
        version - The http version header value to use
        Returns:
        The altered HttpMessage
      • status

        public HttpMessage status​(org.springframework.http.HttpStatus statusCode)
        Sets the Http response status code.
        Parameters:
        statusCode - The status code header to respond with
        Returns:
        The altered HttpMessage
      • statusCode

        public HttpMessage statusCode​(Integer statusCode)
        Sets the Http response status code header.
        Parameters:
        statusCode - The status code header value to respond with
        Returns:
        The altered HttpMessage
      • reasonPhrase

        public HttpMessage reasonPhrase​(String reasonPhrase)
        Sets the Http response reason phrase header.
        Parameters:
        reasonPhrase - The reason phrase header value to use
        Returns:
        The altered HttpMessage
      • uri

        public HttpMessage uri​(String requestUri)
        Sets the Http request request uri header.
        Parameters:
        requestUri - The request uri header value to use
        Returns:
        The altered HttpMessage
      • contentType

        public HttpMessage contentType​(String contentType)
        Sets the Http request content type header.
        Parameters:
        contentType - The content type header value to use
        Returns:
        The altered HttpMessage
      • accept

        public HttpMessage accept​(String accept)
        Sets the Http accepted content type header for response.
        Parameters:
        accept - The accept header value to set
        Returns:
        The altered HttpMessage
      • contextPath

        public HttpMessage contextPath​(String contextPath)
        Sets the Http request context path header.
        Parameters:
        contextPath - The context path header value to use
        Returns:
        The altered HttpMessage
      • queryParams

        public HttpMessage queryParams​(String queryParamString)
        Sets the Http request query params query String. Query String is a compilation of key-value pairs separated by comma character e.g. key1=value1[","key2=value2]. Query String can be empty.
        Parameters:
        queryParamString - The query parameter string to evaluate
        Returns:
        The altered HttpMessage
      • queryParam

        public HttpMessage queryParam​(String name)
        Sets a new Http request query param.
        Parameters:
        name - The name of the request query parameter
        Returns:
        The altered HttpMessage
      • queryParam

        public HttpMessage queryParam​(String name,
                                      String value)
        Sets a new Http request query param.
        Parameters:
        name - The name of the request query parameter
        value - The value of the request query parameter
        Returns:
        The altered HttpMessage
      • path

        public HttpMessage path​(String path)
        Sets request path that is dynamically added to base uri.
        Parameters:
        path - The part of the path to add
        Returns:
        The altered HttpMessage
      • header

        public HttpMessage header​(String headerName,
                                  Object headerValue)
        Sets new header name value pair.
        Parameters:
        headerName - The name of the header
        headerValue - The value of the header
        Returns:
        The altered HttpMessage
      • getRequestMethod

        public org.springframework.http.HttpMethod getRequestMethod()
        Gets the Http request method.
        Returns:
        The used HttpMethod
      • getUri

        public String getUri()
        Gets the Http request request uri.
        Returns:
        The request uri
      • getContextPath

        public String getContextPath()
        Gets the Http request context path.
        Returns:
        the context path
      • getContentType

        public String getContentType()
        Gets the Http content type header.
        Returns:
        the content type header value
      • getAccept

        public String getAccept()
        Gets the accept header.
        Returns:
        The accept header value
      • getQueryParams

        public Map<String,​Collection<String>> getQueryParams()
        Gets the Http request query params.
        Returns:
        The query parameters as a key value map
      • getQueryParamString

        public String getQueryParamString()
        Gets the Http request query param string.
        Returns:
        The query parameter as string
      • getStatusCode

        public org.springframework.http.HttpStatus getStatusCode()
        Gets the Http response status code.
        Returns:
        The status code of the message
      • getReasonPhrase

        public String getReasonPhrase()
        Gets the Http response reason phrase.
        Returns:
        The reason phrase of the message
      • getVersion

        public String getVersion()
        Gets the Http version.
        Returns:
        The http version of the message
      • getPath

        public String getPath()
        Gets the request path after the context path.
        Returns:
        The request path of the message
      • getCookies

        public List<javax.servlet.http.Cookie> getCookies()
        Gets the cookies.
        Returns:
        The list of cookies for this message
      • setCookies

        public void setCookies​(javax.servlet.http.Cookie[] cookies)
        Sets the cookies.
        Parameters:
        cookies - The cookies to set
      • cookie

        public HttpMessage cookie​(javax.servlet.http.Cookie cookie)
        Adds new cookie to this http message.
        Parameters:
        cookie - The Cookie to set
        Returns:
        The altered HttpMessage
      • fromRequestData

        public static HttpMessage fromRequestData​(String requestData)
        Reads request from complete request dump.
        Parameters:
        requestData - The request dump to parse
        Returns:
        The parsed dump as HttpMessage
      • fromResponseData

        public static HttpMessage fromResponseData​(String responseData)
        Reads response from complete response dump.
        Parameters:
        responseData - The response dump to parse
        Returns:
        The parsed dump as HttpMessage