Interface HttpResponse

All Superinterfaces:
HttpMessage
All Known Subinterfaces:
HttpResponseReceived, InterceptedResponse

public interface HttpResponse extends HttpMessage
Burp HTTP response able to retrieve and modify details about an HTTP response.
  • 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

      boolean isStatusCodeClass(StatusCodeClass statusCodeClass)
      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

      List<Cookie> 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

      Cookie cookie(String name)
      Parameters:
      name - The name of the cookie to find.
      Returns:
      An instance of Cookie that matches the name provided. null if not found.
    • cookieValue

      String cookieValue(String name)
      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

      boolean hasCookie(String name)
      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

      boolean hasCookie(Cookie cookie)
      Parameters:
      cookie - An instance of Cookie to check if it exists in the response.
      Returns:
      true If a cookie exists within the response that matches the Cookie provided. false if not.
    • 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

      List<KeywordCount> keywordCounts(String... keywords)
      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

      List<Attribute> attributes(AttributeType... types)
      Retrieve the values of response attributes.
      Parameters:
      types - Response attributes to retrieve values for.
      Returns:
      List of Attribute objects.
    • hasHeader

      boolean hasHeader(HttpHeader header)
      Specified by:
      hasHeader in interface HttpMessage
      Parameters:
      header - The header to check if it exists in the request.
      Returns:
      True if the header exists in the request.
    • hasHeader

      boolean hasHeader(String name)
      Specified by:
      hasHeader in interface HttpMessage
      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

      boolean hasHeader(String name, String value)
      Specified by:
      hasHeader in interface HttpMessage
      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

      HttpHeader header(String name)
      Specified by:
      header in interface HttpMessage
      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

      String headerValue(String name)
      Specified by:
      headerValue in interface HttpMessage
      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 interface HttpMessage
      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 interface HttpMessage
      Returns:
      Version string
    • bodyOffset

      int bodyOffset()
      Offset within the message where the message body begins.
      Specified by:
      bodyOffset in interface HttpMessage
      Returns:
      The message body offset.
    • body

      ByteArray body()
      Body of a message as a byte array.
      Specified by:
      body in interface HttpMessage
      Returns:
      The body of a message as a byte array.
    • bodyToString

      String bodyToString()
      Body of a message as a String.
      Specified by:
      bodyToString in interface HttpMessage
      Returns:
      The body of a message as a String.
    • markers

      List<Marker> markers()
      Markers for the message.
      Specified by:
      markers in interface HttpMessage
      Returns:
      A list of markers.
    • contains

      boolean contains(String searchTerm, boolean caseSensitive)
      Searches the data in the HTTP message for the specified search term.
      Specified by:
      contains in interface HttpMessage
      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

      boolean contains(Pattern pattern)
      Searches the data in the HTTP message for the specified regular expression.
      Specified by:
      contains in interface HttpMessage
      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 interface HttpMessage
      Returns:
      The message as a byte array.
    • toString

      String toString()
      Message as a String.
      Specified by:
      toString in interface HttpMessage
      Overrides:
      toString in class Object
      Returns:
      The message as a String.
    • copyToTempFile

      HttpResponse copyToTempFile()
      Create a copy of the HttpResponse in temporary file.
      This method is used to save the HttpResponse object to a temporary file, so that it is no longer held in memory. Extensions can use this method to convert HttpResponse objects into a form suitable for long-term usage.
      Returns:
      A new HttpResponse instance stored in temporary file.
    • withStatusCode

      HttpResponse withStatusCode(short statusCode)
      Create a copy of the HttpResponse with the provided status code.
      Parameters:
      statusCode - the new status code for response
      Returns:
      A new HttpResponse instance.
    • withReasonPhrase

      HttpResponse withReasonPhrase(String reasonPhrase)
      Create a copy of the HttpResponse with the new reason phrase.
      Parameters:
      reasonPhrase - the new reason phrase for response
      Returns:
      A new HttpResponse instance.
    • withHttpVersion

      HttpResponse withHttpVersion(String httpVersion)
      Create a copy of the HttpResponse with the new http version.
      Parameters:
      httpVersion - the new http version for response
      Returns:
      A new HttpResponse instance.
    • withBody

      HttpResponse withBody(String body)
      Create a copy of the HttpResponse 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)
      Create a copy of the HttpResponse with the updated body.
      Updates Content-Length header.
      Parameters:
      body - the new body for the response
      Returns:
      A new HttpResponse instance.
    • withAddedHeader

      HttpResponse withAddedHeader(HttpHeader header)
      Create a copy of the HttpResponse with the added header.
      Parameters:
      header - The HttpHeader to add to the response.
      Returns:
      The updated response containing the added header.
    • withAddedHeader

      HttpResponse withAddedHeader(String name, String value)
      Create a copy of the HttpResponse 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

      HttpResponse withAddedHeaders(List<? extends HttpHeader> headers)
      Create a copy of the HttpResponse with the added HTTP headers.
      Parameters:
      headers - HTTP headers to add.
      Returns:
      A new HttpResponse instance.
    • withAddedHeaders

      HttpResponse withAddedHeaders(HttpHeader... headers)
      Create a copy of the HttpResponse with the added HTTP headers.
      Parameters:
      headers - HTTP headers to add.
      Returns:
      A new HttpResponse instance.
    • withUpdatedHeader

      HttpResponse withUpdatedHeader(HttpHeader header)
      Create a copy of the HttpResponse with the updated header.
      Parameters:
      header - The HttpHeader to update containing the new value.
      Returns:
      The updated response containing the updated header.
    • withUpdatedHeader

      HttpResponse withUpdatedHeader(String name, String value)
      Create a copy of the HttpResponse 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

      HttpResponse withUpdatedHeaders(List<? extends HttpHeader> headers)
      Create a copy of the HttpResponse with the updated HTTP headers.
      Parameters:
      headers - HTTP headers to update.
      Returns:
      A new HttpResponse instance.
    • withUpdatedHeaders

      HttpResponse withUpdatedHeaders(HttpHeader... headers)
      Create a copy of the HttpResponse with the updated HTTP headers.
      Parameters:
      headers - HTTP headers to update.
      Returns:
      A new HttpResponse instance.
    • withRemovedHeader

      HttpResponse withRemovedHeader(HttpHeader header)
      Create a copy of the HttpResponse with the removed header.
      Parameters:
      header - The HttpHeader to remove from the response.
      Returns:
      The updated response containing the removed header.
    • withRemovedHeader

      HttpResponse withRemovedHeader(String name)
      Create a copy of the HttpResponse 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

      HttpResponse withRemovedHeaders(List<? extends HttpHeader> headers)
      Create a copy of the HttpResponse with the removed HTTP headers.
      Parameters:
      headers - HTTP headers to remove.
      Returns:
      A new HttpResponse instance.
    • withRemovedHeaders

      HttpResponse withRemovedHeaders(HttpHeader... headers)
      Create a copy of the HttpResponse with the removed HTTP headers.
      Parameters:
      headers - HTTP headers to remove.
      Returns:
      A new HttpResponse instance.
    • withMarkers

      HttpResponse withMarkers(List<Marker> markers)
      Create a copy of the HttpResponse with the added markers.
      Parameters:
      markers - Request markers to add.
      Returns:
      A new MarkedHttpRequestResponse instance.
    • withMarkers

      HttpResponse withMarkers(Marker... markers)
      Create a copy of the HttpResponse with the added markers.
      Parameters:
      markers - Request markers to add.
      Returns:
      A new MarkedHttpRequestResponse instance.
    • httpResponse

      static HttpResponse httpResponse()
      Create a new empty instance of HttpResponse.
      Returns:
      A new HttpResponse instance.
    • httpResponse

      static HttpResponse httpResponse(ByteArray response)
      Create a new instance of HttpResponse.
      Parameters:
      response - The HTTP response.
      Returns:
      A new HttpResponse instance.
    • httpResponse

      static HttpResponse httpResponse(String response)
      Create a new instance of HttpResponse.
      Parameters:
      response - The HTTP response.
      Returns:
      A new HttpResponse instance.