Interface HttpRequest
- All Superinterfaces:
HttpMessage
- All Known Subinterfaces:
HttpRequestToBeSent,InterceptedRequest
Burp HTTP request able to retrieve and modify details of an HTTP request.
-
Method Summary
Modifier and TypeMethodDescriptionbody()Body of a message as a byte array.intOffset within the message where the message body begins.Body of a message as aString.Create a copy of theHttpRequestin temporary file.
This method is used to save theHttpRequestobject to a temporary file, so that it is no longer held in memory.headers()HTTP headers contained in the message.static HttpRequesthttp2Request(HttpService service, List<HttpHeader> headers, ByteArray body) Create a new instance ofHttpRequestcontaining HTTP 2 headers and body.static HttpRequesthttp2Request(HttpService service, List<HttpHeader> headers, String body) Create a new instance ofHttpRequestcontaining HTTP 2 headers and body.static HttpRequestCreate a new empty instance ofHttpRequest.static HttpRequesthttpRequest(ByteArray request) Create a new instance ofHttpRequest.static HttpRequesthttpRequest(HttpService service, ByteArray request) Create a new instance ofHttpRequest.static HttpRequesthttpRequest(HttpService service, String request) Create a new instance ofHttpRequest.static HttpRequesthttpRequest(String request) Create a new instance ofHttpRequest.static HttpRequesthttpRequestFromUrl(String url) Create a new instance ofHttpRequest.HTTP service for the request.HTTP Version text parsed from the request line for HTTP 1 messages.markers()Markers for the message.method()HTTP method for the request.path()Path and File for the request.Message as a byte array.toString()Message as aString.url()URL for the request.withAddedHeader(HttpHeader header) Create a copy of theHttpRequestwith the added header.withAddedHeader(String name, String value) Create a copy of theHttpRequestwith the added header.withAddedParameters(HttpParameter... parameters) Create a copy of theHttpRequestwith the added HTTP parameters.withAddedParameters(List<HttpParameter> parameters) Create a copy of theHttpRequestwith the added HTTP parameters.Create a copy of theHttpRequestwith the updated body.
Updates Content-Length header.Create a copy of theHttpRequestwith the updated body.
Updates Content-Length header.Create a copy of theHttpRequestwith added default headers.withHeader(HttpHeader header) Create a copy of theHttpRequestwith the added or updated header.
If the header exists in the request, it is updated.
If the header doesn't exist in the request, it is added.withHeader(String name, String value) Create a copy of theHttpRequestwith the added or updated header.
If the header exists in the request, it is updated.
If the header doesn't exist in the request, it is added.withMarkers(Marker... markers) Create a copy of theHttpRequestwith the added markers.withMarkers(List<Marker> markers) Create a copy of theHttpRequestwith the added markers.withMethod(String method) Create a copy of theHttpRequestwith the new method.withParameter(HttpParameter parameters) Create a copy of theHttpRequestwith the HTTP parameter.
If the parameter exists in the request, it is updated.
If the parameter doesn't exist in the request, it is added.Create a copy of theHttpRequestwith the new path.withRemovedHeader(HttpHeader header) Removes an existing HTTP header from the current request.withRemovedHeader(String name) Removes an existing HTTP header from the current request.withRemovedParameters(HttpParameter... parameters) Create a copy of theHttpRequestwith the removed HTTP parameters.withRemovedParameters(List<HttpParameter> parameters) Create a copy of theHttpRequestwith the removed HTTP parameters.withService(HttpService service) Create a copy of theHttpRequestwith the new service.withTransformationApplied(HttpTransformation transformation) Create a copy of theHttpRequestwith the transformation applied.withUpdatedHeader(HttpHeader header) Create a copy of theHttpRequestwith the updated header.withUpdatedHeader(String name, String value) Create a copy of theHttpRequestwith the updated header.withUpdatedParameters(HttpParameter... parameters) Create a copy of theHttpRequestwith the updated HTTP parameters.withUpdatedParameters(List<HttpParameter> parameters) Create a copy of theHttpRequestwith the updated HTTP parameters.
-
Method Details
-
httpService
HttpService httpService()HTTP service for the request.- Returns:
- An
HttpServiceobject containing details of the HTTP service.
-
url
String url()URL for the request. If the request is malformed, then aMalformedRequestExceptionis thrown.- Returns:
- The URL in the request.
- Throws:
MalformedRequestException- if request is malformed.
-
method
String method()HTTP method for the request. If the request is malformed, then aMalformedRequestExceptionis thrown.- Returns:
- The HTTP method used in the request.
- Throws:
MalformedRequestException- if request is malformed.
-
path
String path()Path and File for the request. If the request is malformed, then aMalformedRequestExceptionis thrown.- Returns:
- the path and file in the request
- Throws:
MalformedRequestException- if request is malformed.
-
httpVersion
String httpVersion()HTTP Version text parsed from the request line for HTTP 1 messages. HTTP 2 messages will return "HTTP/2"- Specified by:
httpVersionin interfaceHttpMessage- Returns:
- Version string
-
headers
List<HttpHeader> headers()HTTP headers contained in the message.- Specified by:
headersin interfaceHttpMessage- Returns:
- A list of HTTP headers.
-
contentType
ContentType contentType()- Returns:
- The detected content type of the request.
-
parameters
List<ParsedHttpParameter> parameters()- Returns:
- The parameters contained in the request.
-
body
ByteArray body()Body of a message as a byte array.- Specified by:
bodyin interfaceHttpMessage- Returns:
- The body of a message as a byte array.
-
bodyToString
String bodyToString()Body of a message as aString.- Specified by:
bodyToStringin interfaceHttpMessage- Returns:
- The body of a message as a
String.
-
bodyOffset
int bodyOffset()Offset within the message where the message body begins.- Specified by:
bodyOffsetin interfaceHttpMessage- Returns:
- The message body offset.
-
markers
Markers for the message.- Specified by:
markersin interfaceHttpMessage- Returns:
- A list of markers.
-
toByteArray
ByteArray toByteArray()Message as a byte array.- Specified by:
toByteArrayin interfaceHttpMessage- Returns:
- The message as a byte array.
-
toString
String toString()Message as aString.- Specified by:
toStringin interfaceHttpMessage- Overrides:
toStringin classObject- Returns:
- The message as a
String.
-
copyToTempFile
HttpRequest copyToTempFile()Create a copy of theHttpRequestin temporary file.
This method is used to save theHttpRequestobject to a temporary file, so that it is no longer held in memory. Extensions can use this method to convertHttpRequestobjects into a form suitable for long-term usage.- Returns:
- A new
HttpRequestinstance stored in temporary file.
-
withService
Create a copy of theHttpRequestwith the new service.- Parameters:
service- AnHttpServicereference to add.- Returns:
- A new
HttpRequestinstance.
-
withPath
Create a copy of theHttpRequestwith the new path.- Parameters:
path- The path to use.- Returns:
- A new
HttpRequestinstance with updated path.
-
withMethod
Create a copy of theHttpRequestwith the new method.- Parameters:
method- the method to use- Returns:
- a new
HttpRequestinstance with updated method.
-
withHeader
Create a copy of theHttpRequestwith the added or updated header.
If the header exists in the request, it is updated.
If the header doesn't exist in the request, it is added.- Parameters:
header- HTTP header to add or update.- Returns:
- A new
HttpRequestwith the added or updated header.
-
withHeader
Create a copy of theHttpRequestwith the added or updated header.
If the header exists in the request, it is updated.
If the header doesn't exist in the request, it is added.- Parameters:
name- The name of the header.value- The value of the header.- Returns:
- A new
HttpRequestwith the added or updated header.
-
withParameter
Create a copy of theHttpRequestwith the HTTP parameter.
If the parameter exists in the request, it is updated.
If the parameter doesn't exist in the request, it is added.- Parameters:
parameters- HTTP parameter to add or update.- Returns:
- A new
HttpRequestwith the added or updated parameter.
-
withAddedParameters
Create a copy of theHttpRequestwith the added HTTP parameters.- Parameters:
parameters- HTTP parameters to add.- Returns:
- A new
HttpRequestinstance.
-
withAddedParameters
Create a copy of theHttpRequestwith the added HTTP parameters.- Parameters:
parameters- HTTP parameters to add.- Returns:
- A new
HttpRequestinstance.
-
withRemovedParameters
Create a copy of theHttpRequestwith the removed HTTP parameters.- Parameters:
parameters- HTTP parameters to remove.- Returns:
- A new
HttpRequestinstance.
-
withRemovedParameters
Create a copy of theHttpRequestwith the removed HTTP parameters.- Parameters:
parameters- HTTP parameters to remove.- Returns:
- A new
HttpRequestinstance.
-
withUpdatedParameters
Create a copy of theHttpRequestwith the updated HTTP parameters.- Parameters:
parameters- HTTP parameters to update.- Returns:
- A new
HttpRequestinstance.
-
withUpdatedParameters
Create a copy of theHttpRequestwith the updated HTTP parameters.- Parameters:
parameters- HTTP parameters to update.- Returns:
- A new
HttpRequestinstance.
-
withTransformationApplied
Create a copy of theHttpRequestwith the transformation applied.- Parameters:
transformation- Transformation to apply.- Returns:
- A new
HttpRequestinstance.
-
withBody
Create a copy of theHttpRequestwith the updated body.
Updates Content-Length header.- Parameters:
body- the new body for the request- Returns:
- A new
HttpRequestinstance.
-
withBody
Create a copy of theHttpRequestwith the updated body.
Updates Content-Length header.- Parameters:
body- the new body for the request- Returns:
- A new
HttpRequestinstance.
-
withAddedHeader
Create a copy of theHttpRequestwith the added header.- Parameters:
name- The name of the header.value- The value of the header.- Returns:
- The updated HTTP request with the added header.
-
withAddedHeader
Create a copy of theHttpRequestwith the added header.- Parameters:
header- TheHttpHeaderto add to the HTTP request.- Returns:
- The updated HTTP request with the added header.
-
withUpdatedHeader
Create a copy of theHttpRequestwith 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 request containing the updated header.
-
withUpdatedHeader
Create a copy of theHttpRequestwith the updated header.- Parameters:
header- TheHttpHeaderto update containing the new value.- Returns:
- The updated request containing the updated header.
-
withRemovedHeader
Removes an existing HTTP header from the current request.- Parameters:
name- The name of the HTTP header to remove from the request.- Returns:
- The updated request containing the removed header.
-
withRemovedHeader
Removes an existing HTTP header from the current request.- Parameters:
header- TheHttpHeaderto remove from the request.- Returns:
- The updated request containing the removed header.
-
withMarkers
Create a copy of theHttpRequestwith the added markers.- Parameters:
markers- Request markers to add.- Returns:
- A new
MarkedHttpRequestResponseinstance.
-
withMarkers
Create a copy of theHttpRequestwith the added markers.- Parameters:
markers- Request markers to add.- Returns:
- A new
MarkedHttpRequestResponseinstance.
-
withDefaultHeaders
HttpRequest withDefaultHeaders()Create a copy of theHttpRequestwith added default headers.- Returns:
- a new (@code HttpRequest) with added default headers
-
httpRequest
Create a new empty instance ofHttpRequest.- Returns:
- A new
HttpRequestinstance.
-
httpRequest
Create a new instance ofHttpRequest.- Parameters:
request- The HTTP request- Returns:
- A new
HttpRequestinstance.
-
httpRequest
Create a new instance ofHttpRequest.- Parameters:
request- The HTTP request.- Returns:
- A new
HttpRequestinstance.
-
httpRequest
Create a new instance ofHttpRequest.- Parameters:
service- An HTTP service for the request.request- The HTTP request.- Returns:
- A new
HttpRequestinstance. A newHttpRequestinstance.
-
httpRequest
Create a new instance ofHttpRequest.- Parameters:
service- An HTTP service for the request.request- The HTTP request.- Returns:
- A new
HttpRequestinstance.
-
httpRequestFromUrl
Create a new instance ofHttpRequest.- Parameters:
url- A URL for the request.- Returns:
- A new
HttpRequestinstance.
-
http2Request
Create a new instance ofHttpRequestcontaining HTTP 2 headers and body.- Parameters:
service- An HTTP service for the request.headers- A list of HTTP 2 headers.body- A body of the HTTP 2 request.- Returns:
- A new
HttpRequestinstance.
-
http2Request
Create a new instance ofHttpRequestcontaining HTTP 2 headers and body.- Parameters:
service- An HTTP service for the request.headers- A list of HTTP 2 headers.body- A body of the HTTP 2 request.- Returns:
- A new
HttpRequestinstance.
-