Package org.citrusframework.http.message
Class HttpMessage
java.lang.Object
org.citrusframework.message.DefaultMessage
org.citrusframework.http.message.HttpMessage
- All Implemented Interfaces:
Serializable,Message
- Since:
- 2.0
- Author:
- Christoph Deppisch
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor initializing with empty message payload.HttpMessage(Object payload) Default message using message payload.HttpMessage(Object payload, Map<String, Object> headers) Default message using message payload and headers.HttpMessage(Message message) Constructs copy of given message. -
Method Summary
Modifier and TypeMethodDescriptionSets the Http accepted content type header for response.addHeaderData(String headerData) contentType(String contentType) Sets the Http request content type header.contextPath(String contextPath) Sets the Http request context path header.cookie(jakarta.servlet.http.Cookie cookie) Adds new cookie to this http message.static HttpMessagefromRequestData(String requestData) Reads request from complete request dump.static HttpMessagefromResponseData(String responseData) Reads response from complete response dump.Gets the accept header.Gets the Http content type header.Gets the Http request context path.List<jakarta.servlet.http.Cookie>Gets the cookies.getPath()Gets the request path after the context path.Gets the Http request query params.Gets the Http request query param string.Gets the Http response reason phrase.org.springframework.web.bind.annotation.RequestMethodGets the Http request method.org.springframework.http.HttpStatusCodeGets the Http response status code.getUri()Gets the Http request request uri.Gets the Http version.Sets new header name value pair.method(org.springframework.http.HttpMethod method) Sets the Http request method header.Sets request path that is dynamically added to base uri.queryParam(String name) Sets a new Http request query param.queryParam(String name, String value) Sets a new Http request query param.queryParams(String queryParamString) Sets the Http request query params query String.reasonPhrase(String reasonPhrase) Sets the Http response reason phrase header.voidsetCookies(jakarta.servlet.http.Cookie[] cookies) Sets the cookies.status(org.springframework.http.HttpStatusCode statusCode) Sets the Http response status code header.Sets the Http request request uri header.Sets the Http version header.Methods inherited from class org.citrusframework.message.DefaultMessage
getHeader, getHeaderData, getHeaders, getId, getName, getPayload, getPayload, getTimestamp, getType, removeHeader, setName, setPayload, setType, setType, toString
-
Constructor Details
-
HttpMessage
public HttpMessage()Empty constructor initializing with empty message payload. -
HttpMessage
Constructs copy of given message.- Parameters:
message- The base message for the copy operation
-
HttpMessage
Default message using message payload.- Parameters:
payload- The payload for the message to set
-
HttpMessage
Default message using message payload and headers.- Parameters:
payload- The payload for the message to setheaders- A key value map containing the headers to set
-
-
Method Details
-
method
Sets the Http request method header.- Parameters:
method- The Http method header to use- Returns:
- The altered HttpMessage
-
version
Sets the Http version header.- Parameters:
version- The http version header value to use- Returns:
- The altered HttpMessage
-
status
Sets the Http response status code header.- Parameters:
statusCode- The status code header value to respond with- Returns:
- The altered HttpMessage
-
reasonPhrase
Sets the Http response reason phrase header.- Parameters:
reasonPhrase- The reason phrase header value to use- Returns:
- The altered HttpMessage
-
uri
Sets the Http request request uri header.- Parameters:
requestUri- The request uri header value to use- Returns:
- The altered HttpMessage
-
contentType
Sets the Http request content type header.- Parameters:
contentType- The content type header value to use- Returns:
- The altered HttpMessage
-
accept
Sets the Http accepted content type header for response.- Parameters:
accept- The accept header value to set- Returns:
- The altered HttpMessage
-
contextPath
Sets the Http request context path header.- Parameters:
contextPath- The context path header value to use- Returns:
- The altered HttpMessage
-
queryParams
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
Sets a new Http request query param.- Parameters:
name- The name of the request query parameter- Returns:
- The altered HttpMessage
-
queryParam
Sets a new Http request query param.- Parameters:
name- The name of the request query parametervalue- The value of the request query parameter- Returns:
- The altered HttpMessage
-
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
Sets new header name value pair.- Parameters:
headerName- The name of the headerheaderValue- The value of the header- Returns:
- The altered HttpMessage
-
setHeader
- Specified by:
setHeaderin interfaceMessage- Overrides:
setHeaderin classDefaultMessage
-
addHeaderData
- Specified by:
addHeaderDatain interfaceMessage- Overrides:
addHeaderDatain classDefaultMessage
-
getRequestMethod
public org.springframework.web.bind.annotation.RequestMethod getRequestMethod()Gets the Http request method.- Returns:
- The used HttpMethod
-
getUri
Gets the Http request request uri.- Returns:
- The request uri
-
getContextPath
Gets the Http request context path.- Returns:
- the context path
-
getContentType
Gets the Http content type header.- Returns:
- the content type header value
-
getAccept
Gets the accept header.- Returns:
- The accept header value
-
getQueryParams
Gets the Http request query params.- Returns:
- The query parameters as a key value map
-
getQueryParamString
Gets the Http request query param string.- Returns:
- The query parameter as string
-
getStatusCode
public org.springframework.http.HttpStatusCode getStatusCode()Gets the Http response status code.- Returns:
- The status code of the message
-
getReasonPhrase
Gets the Http response reason phrase.- Returns:
- The reason phrase of the message
-
getVersion
Gets the Http version.- Returns:
- The http version of the message
-
getPath
Gets the request path after the context path.- Returns:
- The request path of the message
-
getCookies
Gets the cookies.- Returns:
- The list of cookies for this message
-
setCookies
public void setCookies(jakarta.servlet.http.Cookie[] cookies) Sets the cookies.- Parameters:
cookies- The cookies to set
-
cookie
Adds new cookie to this http message.- Parameters:
cookie- The Cookie to set- Returns:
- The altered HttpMessage
-
fromRequestData
Reads request from complete request dump.- Parameters:
requestData- The request dump to parse- Returns:
- The parsed dump as HttpMessage
-
fromResponseData
Reads response from complete response dump.- Parameters:
responseData- The response dump to parse- Returns:
- The parsed dump as HttpMessage
-