Modifier and Type | Field and Description |
---|---|
static String |
EVENT_DATA_REQUEST_BODY |
static String |
EVENT_DATA_REQUEST_HEADER |
static String |
EVENT_DATA_RESPONSE_BODY |
static String |
EVENT_DATA_RESPONSE_HEADER |
static String |
EVENT_DATA_URI |
static String |
MESSAGE_TYPE |
Constructor and Description |
---|
HttpMessage()
Constructor for a empty HTTP message.
|
HttpMessage(HttpMessage message)
Constructs a
HttpMessage from the given message. |
HttpMessage(HttpRequestHeader reqHeader)
Constructs an HTTP message with the given request header.
|
HttpMessage(HttpRequestHeader reqHeader,
HttpRequestBody reqBody)
Constructs an HTTP message with the given request header and request body.
|
HttpMessage(HttpRequestHeader reqHeader,
HttpRequestBody reqBody,
HttpResponseHeader resHeader,
HttpResponseBody resBody)
Constructor for a HTTP message with given request and response pair.
|
HttpMessage(String reqHeader,
byte[] reqBody,
String resHeader,
byte[] resBody) |
HttpMessage(org.apache.commons.httpclient.URI uri)
Constructs a
HttpMessage with a HTTP/1.1 GET request to the given URI. |
HttpMessage(org.apache.commons.httpclient.URI uri,
ConnectionParam params)
Deprecated.
(2.8.0) Use
HttpMessage(URI) instead. |
Modifier and Type | Method and Description |
---|---|
HttpMessage |
cloneAll()
Clones this message.
|
HttpMessage |
cloneRequest()
Clones the request of this message.
|
boolean |
equals(Object object)
Compare if 2 message is the same.
|
boolean |
equalType(HttpMessage msg)
Compares this
HttpMessage against another. |
TreeSet<HtmlParameter> |
getCookieParams() |
String |
getCookieParamsAsString() |
TreeSet<HtmlParameter> |
getFormParams() |
HistoryReference |
getHistoryRef() |
HttpSession |
getHttpSession()
Gets the http session associated with this message.
|
String |
getNote() |
List<String> |
getParameterNames(HtmlParameter.Type type)
Returns the names of the parameters of the given
type in a List. |
List<HtmlParameter> |
getParameters(HtmlParameter.Type type)
Returns the parameters of the given
type in a List. |
String[] |
getParamNames() |
TreeSet<String> |
getParamNameSet(HtmlParameter.Type type)
Returns the names of the parameters of the given
type . |
HttpRequestBody |
getRequestBody()
Gets the request body of this message.
|
HttpRequestHeader |
getRequestHeader()
Gets the request header of this message.
|
User |
getRequestingUser()
Gets the request user.
|
HttpResponseBody |
getResponseBody()
Gets the response body of this message.
|
HttpResponseHeader |
getResponseHeader()
Gets the response header of this message.
|
int |
getTimeElapsedMillis() |
long |
getTimeSentMillis()
Get the starting time when the request is going to be sent.
|
String |
getType()
Returns "HTTP"
|
TreeSet<HtmlParameter> |
getUrlParams() |
Object |
getUserObject() |
int |
hashCode() |
boolean |
isEventStream()
ZAP: New method checking if connection is a Server-Sent Events stream.
|
boolean |
isForceIntercept() |
boolean |
isInScope() |
boolean |
isResponseFromTargetHost()
Tells whether or not the response has been received from the target host.
|
boolean |
isWebSocketUpgrade()
ZAP: New method checking for connection upgrade.
|
void |
mutateHttpMethod(String method) |
static void |
setContentEncodings(HttpHeader header,
HttpBody body)
Sets the content encodings defined in the header into the body.
|
void |
setCookieParams(TreeSet<HtmlParameter> cookieParams) |
void |
setCookieParamsAsString(String data) |
void |
setCookies(List<HttpCookie> cookies) |
void |
setForceIntercept(boolean force) |
void |
setFormParams(TreeSet<HtmlParameter> postParams) |
void |
setGetParams(TreeSet<HtmlParameter> getParams) |
void |
setHistoryRef(HistoryReference historyRef) |
void |
setHttpSession(HttpSession session)
Sets the http session associated with this message.
|
void |
setNote(String note) |
void |
setRequestBody(byte[] body)
Sets the given byte body as the request body.
|
void |
setRequestBody(HttpRequestBody reqBody)
Sets the request body of this message.
|
void |
setRequestBody(String body)
Sets the given string body as the request body.
|
void |
setRequestHeader(HttpRequestHeader reqHeader)
Sets the request header of this message.
|
void |
setRequestHeader(String reqHeader)
Sets the given string as the request header.
|
void |
setRequestingUser(User requestUser)
Sets the requesting user.
|
void |
setResponseBody(byte[] body)
Sets the given byte body as the response body.
|
void |
setResponseBody(HttpResponseBody resBody)
Sets the response body of this message.
|
void |
setResponseBody(String body)
Sets the given string body as the response body.
|
void |
setResponseFromTargetHost(boolean responseFromTargetHost)
Sets if the response has been received or not from the target host.
|
void |
setResponseHeader(HttpResponseHeader resHeader)
Sets the response header of this message.
|
void |
setResponseHeader(String resHeader)
Sets the given string as the response header.
|
void |
setTimeElapsedMillis(int timeElapsed)
Set the elapsed time (time difference) between the request is sent and all response is
received.
|
void |
setTimeSentMillis(long timeSent)
Set the time when the request is sent.
|
void |
setUserObject(Object userObject) |
Map<String,String> |
toEventData()
Returns a map of data suitable for including in an
Event |
public static final String EVENT_DATA_URI
public static final String EVENT_DATA_REQUEST_HEADER
public static final String EVENT_DATA_REQUEST_BODY
public static final String EVENT_DATA_RESPONSE_HEADER
public static final String EVENT_DATA_RESPONSE_BODY
public static final String MESSAGE_TYPE
public HttpMessage()
public HttpMessage(org.apache.commons.httpclient.URI uri) throws HttpMalformedHeaderException
HttpMessage
with a HTTP/1.1 GET request to the given URI.
The following headers are automatically added:
Host
, with the domain and port from the given URI.
User-Agent
, using the HttpRequestHeader.getDefaultUserAgent()
.
Pragma: no-cache
Cache-Control: no-cache
, if version is HTTP/1.1
Content-Type: application/x-www-form-urlencoded
, if the method is POST or PUT.
uri
- the request target.HttpMalformedHeaderException
- if the resulting HTTP header is malformed.@Deprecated public HttpMessage(org.apache.commons.httpclient.URI uri, ConnectionParam params) throws HttpMalformedHeaderException
HttpMessage(URI)
instead.HttpMessage
with a HTTP/1.1 GET request to the given URI.
The following headers are automatically added:
Host
, with the domain and port from the given URI.
User-Agent
, using the HttpRequestHeader.getDefaultUserAgent()
.
Pragma: no-cache
Cache-Control: no-cache
, if version is HTTP/1.1
Content-Type: application/x-www-form-urlencoded
, if the method is POST or PUT.
uri
- the request target.params
- unused.HttpMalformedHeaderException
- if the resulting HTTP header is malformed.public HttpMessage(HttpRequestHeader reqHeader)
reqHeader
- the request headerIllegalArgumentException
- if the parameter reqHeader
is null
.public HttpMessage(HttpRequestHeader reqHeader, HttpRequestBody reqBody)
reqHeader
- the request headerreqBody
- the request bodyIllegalArgumentException
- if the parameter reqHeader
or reqBody
are
null
.public HttpMessage(HttpRequestHeader reqHeader, HttpRequestBody reqBody, HttpResponseHeader resHeader, HttpResponseBody resBody)
reqHeader
- the request headerreqBody
- the request bodyresHeader
- the response headerresBody
- the response bodyIllegalArgumentException
- if one of the parameters is null
.public HttpMessage(String reqHeader, byte[] reqBody, String resHeader, byte[] resBody) throws HttpMalformedHeaderException
HttpMalformedHeaderException
public HttpMessage(HttpMessage message)
HttpMessage
from the given message.
All the HttpMessage
state is copied, except for the following which are the same:
message
- the message to copy.public HistoryReference getHistoryRef()
public void setHistoryRef(HistoryReference historyRef)
public HttpSession getHttpSession()
public void setHttpSession(HttpSession session)
session
- the new http sessionpublic HttpRequestHeader getRequestHeader()
null
public void setRequestHeader(HttpRequestHeader reqHeader)
reqHeader
- the new request headerIllegalArgumentException
- if parameter reqHeader
is null
.public HttpResponseHeader getResponseHeader()
To know if a response has been set call the method HttpResponseHeader#isEmpty()
on
the returned response header. The response header is initially empty.
null
HttpHeader.isEmpty()
public void setResponseHeader(HttpResponseHeader resHeader)
resHeader
- the new response headerIllegalArgumentException
- if parameter resHeader
is null
.public HttpRequestBody getRequestBody()
null
public void setRequestBody(HttpRequestBody reqBody)
Note: No encodings are set to the request body to match the header.
reqBody
- the new request bodyIllegalArgumentException
- if parameter reqBody
is null
.public HttpResponseBody getResponseBody()
null
public void setResponseBody(HttpResponseBody resBody)
Note: No encodings are set to the response body to match the header.
resBody
- the new response bodyIllegalArgumentException
- if parameter resBody
is null
.public void setRequestHeader(String reqHeader) throws HttpMalformedHeaderException
Note: No encodings are set to the request body to match the header.
reqHeader
- the new request header.HttpMalformedHeaderException
- if the given header is malformed.setContentEncodings(HttpHeader, HttpBody)
public void setResponseHeader(String resHeader) throws HttpMalformedHeaderException
Note: No encodings are set to the response body to match the header.
resHeader
- the new response header.HttpMalformedHeaderException
- if the given header is malformed.setContentEncodings(HttpHeader, HttpBody)
public static void setContentEncodings(HttpHeader header, HttpBody body)
Note: Supports only gzip
and deflate
.
header
- the header.body
- the body.public void setRequestBody(String body)
The defined request header content encodings are set to the body, the string body will be encoded accordingly.
body
- the new body.HttpBody.setContentEncodings(List)
public void setRequestBody(byte[] body)
The defined request header content encodings are set to the body, the byte body is assumed to be properly encoded.
body
- the new body.HttpBody.setContentEncodings(List)
public void setResponseBody(String body)
The defined response header content encodings are set to the body, the string body will be encoded accordingly.
body
- the new body.HttpBody.setContentEncodings(List)
public void setResponseBody(byte[] body)
The defined response header content encodings are set to the body, the byte body is assumed to be properly encoded.
body
- the new body.HttpBody.setContentEncodings(List)
public boolean equals(Object object)
public boolean equalType(HttpMessage msg)
HttpMessage
against another. Messages are equal type if the host, port,
path and parameter names are equal. Even though the query values may differ. For POST this
assumes x-www-form-urlencoded, for other types (such as JSON) this means that parameter names
and values (the full request body) could be included.msg
- the message against which this HttpMessage
is being compared.true
if the messages are considered equal, false
otherwisepublic TreeSet<String> getParamNameSet(HtmlParameter.Type type)
type
. As a Set is used no names will
be duplicated.type
- the type of the parameters that will be extracted from the messageTreeSet
with the names of the parameters of the given type
, never
null
public List<String> getParameterNames(HtmlParameter.Type type)
type
in a List. The List can return
duplicated names.type
- the type of the parameters that will be extracted from the messageList
with the names of the parameters of the given type
, never
null
public List<HtmlParameter> getParameters(HtmlParameter.Type type)
type
in a List. The List can return duplicated
parameter names.type
- the type of the parameters that will be extracted from the messageList
with the parameters of the given type
, never null
public String[] getParamNames()
public TreeSet<HtmlParameter> getUrlParams()
public TreeSet<HtmlParameter> getFormParams()
public void setCookieParamsAsString(String data)
public String getCookieParamsAsString()
public TreeSet<HtmlParameter> getCookieParams()
public Object getUserObject()
public void setUserObject(Object userObject)
userObject
- The userObject to set.public HttpMessage cloneAll()
It returns a new HttpMessage
with a copy of the request/response headers and
bodies, no other state is copied.
HttpMessage
with the same (contents) request/response headers and
bodies as this one.HttpMessage(HttpMessage)
public HttpMessage cloneRequest()
It returns a new HttpMessage
with a copy of the request header and body, no other
state is copied.
HttpMessage
with the same (contents) request header and body as this
one.HttpMessage(HttpMessage)
public int getTimeElapsedMillis()
public void setTimeElapsedMillis(int timeElapsed)
timeElapsed
- public long getTimeSentMillis()
public void setTimeSentMillis(long timeSent)
timeSent
- The timeSent to set.public String getNote()
public void setNote(String note)
note
- The note to set.public void mutateHttpMethod(String method)
public void setFormParams(TreeSet<HtmlParameter> postParams)
public void setGetParams(TreeSet<HtmlParameter> getParams)
public void setCookieParams(TreeSet<HtmlParameter> cookieParams)
public boolean isWebSocketUpgrade()
public void setCookies(List<HttpCookie> cookies)
public boolean isEventStream()
public boolean isForceIntercept()
isForceIntercept
in interface Message
public void setForceIntercept(boolean force)
public User getRequestingUser()
public void setRequestingUser(User requestUser)
requestUser
- the new request userpublic boolean isResponseFromTargetHost()
Note: No distinction is done between responses from intermediate proxy servers (if any) and the target host.
true
if the response has been received from the target host, false
otherwise.public void setResponseFromTargetHost(boolean responseFromTargetHost)
responseFromTargetHost
- true
if the response has been received from the target
host, false
otherwise.public Map<String,String> toEventData()
Event
toEventData
in interface Message