The Burp Suite User Forum was discontinued on the 1st November 2024.

Burp Suite User Forum

For support requests, go to the Support Center. To discuss with other Burp users, head to our Discord page.

SUPPORT CENTER DISCORD

Re-writing responses

Jay | Last updated: Jul 29, 2015 09:02PM UTC

I am trying to write my first extension to add a csp header to the response. I have found several articles about adding headers to the requests but none for responses. This if my first try, which does not work. Any pointers to fix this would be appreciated. Thanks! def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo): # determine what tool we would like to pass though our extension: if toolFlag == 4: if not messageIsRequest: response = messageInfo.getResponse() responseStr = self._callbacks.getHelpers().bytesToString(response) responseParsed = self._helpers.analyzeResponse(response) body = responseStr[responseParsed.getBodyOffset():] headers = responseParsed.getHeaders() headers.add('MYHEADER: CSP') httpResponse = self._callbacks.getHelpers().buildHttpMessage(headers, body)

PortSwigger Agent | Last updated: Jul 30, 2015 03:21PM UTC