title: Burp Extension: add header to response
body: <p>Burp newbie writing an extension... I am trying to add a header to the response to test CSP rules. I have found lots of resources to add headers to Requests, but not for Responses. Here is the (non-working) code I have so far:</p>
  
  <pre><code>def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo):
  
      # determine what tool we would like to pass though our extension:
      if toolFlag == 4: #if tool is Proxy Tab
          # determine if request or response:
          if not messageIsRequest:#only handle responses
              response = messageInfo.getResponse() #get Response from IHttpRequestResponse instance
              responseStr = self._callbacks.getHelpers().bytesToString(response)
              responseParsed = self._helpers.analyzeResponse(response)
              body = responseStr[responseParsed.getBodyOffset():]
              headers = responseParsed.getHeaders()
  
              headers.add('MYHEADER: TEST')
  
              httpResponse = self._callbacks.getHelpers().buildHttpMessage(headers, body)
              return
  </code></pre>