Interface HttpResponse
- All Superinterfaces:
HttpMessage
- All Known Subinterfaces:
HttpResponseReceived
,InterceptedResponse
Burp HTTP response able to retrieve and modify details about an HTTP response.
-
Method Summary
Modifier and TypeMethodDescriptionattributes
(AttributeType... types) Retrieve the values of response attributes.body()
Body of a message as a byte array.int
Offset within the message where the message body begins.Body of a message as aString
.boolean
Searches the data in the HTTP message for the specified search term.boolean
Searches the data in the HTTP message for the specified regular expression.cookies()
Obtain details of the HTTP cookies set in the response.cookieValue
(String name) Create a copy of theHttpResponse
in temporary file.
This method is used to save theHttpResponse
object to a temporary file, so that it is no longer held in memory.boolean
boolean
boolean
hasHeader
(HttpHeader header) boolean
boolean
headers()
HTTP headers contained in the message.headerValue
(String name) static HttpResponse
Create a new empty instance ofHttpResponse
.static HttpResponse
httpResponse
(ByteArray response) Create a new instance ofHttpResponse
.static HttpResponse
httpResponse
(String response) Create a new instance ofHttpResponse
.HTTP Version text parsed from the request or response line for HTTP 1 messages.Obtain the MIME type of the response, as inferred from the contents of the HTTP message body.boolean
isStatusCodeClass
(StatusCodeClass statusCodeClass) Test whether the status code is in the specified class.keywordCounts
(String... keywords) Retrieve the number of types given keywords appear in the response.markers()
Markers for the message.mimeType()
Obtain the MIME type of the response, as determined by Burp Suite.Obtain the HTTP reason phrase contained in the response for HTTP 1 messages.Obtain the MIME type of the response, as stated in the HTTP headers.short
Obtain the HTTP status code contained in the response.Message as a byte array.toString()
Message as aString
.withAddedHeader
(HttpHeader header) Create a copy of theHttpResponse
with the added header.withAddedHeader
(String name, String value) Create a copy of theHttpResponse
with the added header.withAddedHeaders
(HttpHeader... headers) Create a copy of theHttpResponse
with the added HTTP headers.withAddedHeaders
(List<? extends HttpHeader> headers) Create a copy of theHttpResponse
with the added HTTP headers.Create a copy of theHttpResponse
with the updated body.
Updates Content-Length header.Create a copy of theHttpResponse
with the updated body.
Updates Content-Length header.withHttpVersion
(String httpVersion) Create a copy of theHttpResponse
with the new http version.withMarkers
(Marker... markers) Create a copy of theHttpResponse
with the added markers.withMarkers
(List<Marker> markers) Create a copy of theHttpResponse
with the added markers.withReasonPhrase
(String reasonPhrase) Create a copy of theHttpResponse
with the new reason phrase.withRemovedHeader
(HttpHeader header) Create a copy of theHttpResponse
with the removed header.withRemovedHeader
(String name) Create a copy of theHttpResponse
with the removed header.withRemovedHeaders
(HttpHeader... headers) Create a copy of theHttpResponse
with the removed HTTP headers.withRemovedHeaders
(List<? extends HttpHeader> headers) Create a copy of theHttpResponse
with the removed HTTP headers.withStatusCode
(short statusCode) Create a copy of theHttpResponse
with the provided status code.withUpdatedHeader
(HttpHeader header) Create a copy of theHttpResponse
with the updated header.withUpdatedHeader
(String name, String value) Create a copy of theHttpResponse
with the updated header.withUpdatedHeaders
(HttpHeader... headers) Create a copy of theHttpResponse
with the updated HTTP headers.withUpdatedHeaders
(List<? extends HttpHeader> headers) Create a copy of theHttpResponse
with the updated HTTP headers.
-
Method Details
-
statusCode
short statusCode()Obtain the HTTP status code contained in the response.- Returns:
- HTTP status code.
-
reasonPhrase
String reasonPhrase()Obtain the HTTP reason phrase contained in the response for HTTP 1 messages. HTTP 2 messages will return a mapped phrase based on the status code.- Returns:
- HTTP Reason phrase.
-
isStatusCodeClass
Test whether the status code is in the specified class.- Parameters:
statusCodeClass
- The class of status code to test.- Returns:
- True if the status code is in the class.
-
cookies
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.
-
cookie
- Parameters:
name
- The name of the cookie to find.- Returns:
- An instance of
Cookie
that matches the name provided.null
if not found.
-
cookieValue
- Parameters:
name
- The name of the cookie to retrieve the value from.- Returns:
- The value of the cookie that matches the name provided.
null
if not found.
-
hasCookie
- Parameters:
name
- The name of the cookie to check if it exists in the response.- Returns:
true
If a cookie exists within the response that matches the name provided.false
if not.
-
hasCookie
-
mimeType
MimeType mimeType()Obtain the MIME type of the response, as determined by Burp Suite.- Returns:
- The MIME type.
-
statedMimeType
MimeType statedMimeType()Obtain the MIME type of the response, as stated in the HTTP headers.- Returns:
- The stated MIME type.
-
inferredMimeType
MimeType inferredMimeType()Obtain the MIME type of the response, as inferred from the contents of the HTTP message body.- Returns:
- The inferred MIME type.
-
keywordCounts
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
Retrieve the values of response attributes.- Parameters:
types
- Response attributes to retrieve values for.- Returns:
- List of
Attribute
objects.
-
hasHeader
- Specified by:
hasHeader
in interfaceHttpMessage
- Parameters:
header
- The header to check if it exists in the request.- Returns:
- True if the header exists in the request.
-
hasHeader
- Specified by:
hasHeader
in interfaceHttpMessage
- Parameters:
name
- The name of the header to query within the request.- Returns:
- True if a header exists in the request with the supplied name.
-
hasHeader
- Specified by:
hasHeader
in interfaceHttpMessage
- Parameters:
name
- The name of the header to check.value
- The value of the header to check.- Returns:
- True if a header exists in the request that matches the name and value supplied.
-
header
- Specified by:
header
in interfaceHttpMessage
- Parameters:
name
- The name of the header to retrieve.- Returns:
- An instance of
HttpHeader
that matches the name supplied,null
if no match found.
-
headerValue
- Specified by:
headerValue
in interfaceHttpMessage
- Parameters:
name
- The name of the header to retrieve.- Returns:
- The
String
value of the header that matches the name supplied,null
if no match found.
-
headers
List<HttpHeader> headers()HTTP headers contained in the message.- Specified by:
headers
in interfaceHttpMessage
- Returns:
- A list of HTTP headers.
-
httpVersion
String httpVersion()HTTP Version text parsed from the request or response line for HTTP 1 messages. HTTP 2 messages will return "HTTP/2"- Specified by:
httpVersion
in interfaceHttpMessage
- Returns:
- Version string
-
bodyOffset
int bodyOffset()Offset within the message where the message body begins.- Specified by:
bodyOffset
in interfaceHttpMessage
- Returns:
- The message body offset.
-
body
ByteArray body()Body of a message as a byte array.- Specified by:
body
in interfaceHttpMessage
- Returns:
- The body of a message as a byte array.
-
bodyToString
String bodyToString()Body of a message as aString
.- Specified by:
bodyToString
in interfaceHttpMessage
- Returns:
- The body of a message as a
String
.
-
markers
Markers for the message.- Specified by:
markers
in interfaceHttpMessage
- Returns:
- A list of markers.
-
contains
Searches the data in the HTTP message for the specified search term.- Specified by:
contains
in interfaceHttpMessage
- Parameters:
searchTerm
- The value to be searched for.caseSensitive
- Flags whether the search is case-sensitive.- Returns:
- True if the search term is found.
-
contains
Searches the data in the HTTP message for the specified regular expression.- Specified by:
contains
in interfaceHttpMessage
- Parameters:
pattern
- The regular expression to be searched for.- Returns:
- True if the pattern is matched.
-
toByteArray
ByteArray toByteArray()Message as a byte array.- Specified by:
toByteArray
in interfaceHttpMessage
- Returns:
- The message as a byte array.
-
toString
String toString()Message as aString
.- Specified by:
toString
in interfaceHttpMessage
- Overrides:
toString
in classObject
- Returns:
- The message as a
String
.
-
copyToTempFile
HttpResponse copyToTempFile()Create a copy of theHttpResponse
in temporary file.
This method is used to save theHttpResponse
object to a temporary file, so that it is no longer held in memory. Extensions can use this method to convertHttpResponse
objects into a form suitable for long-term usage.- Returns:
- A new
HttpResponse
instance stored in temporary file.
-
withStatusCode
Create a copy of theHttpResponse
with the provided status code.- Parameters:
statusCode
- the new status code for response- Returns:
- A new
HttpResponse
instance.
-
withReasonPhrase
Create a copy of theHttpResponse
with the new reason phrase.- Parameters:
reasonPhrase
- the new reason phrase for response- Returns:
- A new
HttpResponse
instance.
-
withHttpVersion
Create a copy of theHttpResponse
with the new http version.- Parameters:
httpVersion
- the new http version for response- Returns:
- A new
HttpResponse
instance.
-
withBody
Create a copy of theHttpResponse
with the updated body.
Updates Content-Length header.- Parameters:
body
- the new body for the response- Returns:
- A new
HttpResponse
instance.
-
withBody
Create a copy of theHttpResponse
with the updated body.
Updates Content-Length header.- Parameters:
body
- the new body for the response- Returns:
- A new
HttpResponse
instance.
-
withAddedHeader
Create a copy of theHttpResponse
with the added header.- Parameters:
header
- TheHttpHeader
to add to the response.- Returns:
- The updated response containing the added header.
-
withAddedHeader
Create a copy of theHttpResponse
with the added header.- Parameters:
name
- The name of the header.value
- The value of the header.- Returns:
- The updated response containing the added header.
-
withAddedHeaders
Create a copy of theHttpResponse
with the added HTTP headers.- Parameters:
headers
- HTTP headers to add.- Returns:
- A new
HttpResponse
instance.
-
withAddedHeaders
Create a copy of theHttpResponse
with the added HTTP headers.- Parameters:
headers
- HTTP headers to add.- Returns:
- A new
HttpResponse
instance.
-
withUpdatedHeader
Create a copy of theHttpResponse
with the updated header.- Parameters:
header
- TheHttpHeader
to update containing the new value.- Returns:
- The updated response containing the updated header.
-
withUpdatedHeader
Create a copy of theHttpResponse
with the updated header.- 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.
-
withUpdatedHeaders
Create a copy of theHttpResponse
with the updated HTTP headers.- Parameters:
headers
- HTTP headers to update.- Returns:
- A new
HttpResponse
instance.
-
withUpdatedHeaders
Create a copy of theHttpResponse
with the updated HTTP headers.- Parameters:
headers
- HTTP headers to update.- Returns:
- A new
HttpResponse
instance.
-
withRemovedHeader
Create a copy of theHttpResponse
with the removed header.- Parameters:
header
- TheHttpHeader
to remove from the response.- Returns:
- The updated response containing the removed header.
-
withRemovedHeader
Create a copy of theHttpResponse
with the removed header.- Parameters:
name
- The name of the HTTP header to remove from the response.- Returns:
- The updated response containing the removed header.
-
withRemovedHeaders
Create a copy of theHttpResponse
with the removed HTTP headers.- Parameters:
headers
- HTTP headers to remove.- Returns:
- A new
HttpResponse
instance.
-
withRemovedHeaders
Create a copy of theHttpResponse
with the removed HTTP headers.- Parameters:
headers
- HTTP headers to remove.- Returns:
- A new
HttpResponse
instance.
-
withMarkers
Create a copy of theHttpResponse
with the added markers.- Parameters:
markers
- Request markers to add.- Returns:
- A new
MarkedHttpRequestResponse
instance.
-
withMarkers
Create a copy of theHttpResponse
with the added markers.- Parameters:
markers
- Request markers to add.- Returns:
- A new
MarkedHttpRequestResponse
instance.
-
httpResponse
Create a new empty instance ofHttpResponse
.- Returns:
- A new
HttpResponse
instance.
-
httpResponse
Create a new instance ofHttpResponse
.- Parameters:
response
- The HTTP response.- Returns:
- A new
HttpResponse
instance.
-
httpResponse
Create a new instance ofHttpResponse
.- Parameters:
response
- The HTTP response.- Returns:
- A new
HttpResponse
instance.
-