Burp Suite User Forum

Login to post

Conditionally/unconditionally add response headers

Gene | Last updated: Apr 02, 2021 03:52PM UTC

I want to conditionally add response headers, but having a hard time knowing if there are any apis to do this easily. I basically want to UNconditionally add some response headers and conditionally add a response header if that header is NOT already in the response headers. Questions: Are there any apis to simply check whether or not a response header exists, or am I stuck with checking the whole IHttpRequestResponse#getResponse as a string? Are there any apis that simply append a response header to the response, or an I stuck with having to use IHttpRequestResponse#getResponse as a string, manipulate it, and them use IHttpRequestResponse#setResponse(<new response as byte[]>)?

Hannah, PortSwigger Agent | Last updated: Apr 06, 2021 10:56AM UTC

IExtensionHelpers has an analyzeResponse() function, which return an IResponseInfo object. This has a function of getHeaders(), which you could use to check whether a particular header is present.

I can't find any useful functions for adding headers straight into the response, so you would likely have to manipulate the IHttpRequestResponse in the way you suggested.

We have some sample extensions that might help you get up and running quickly - you can find them here

You need to Log in to post a reply. Or register here, for free.