'Check for the error message in the duplicated header'

def test_malformedHeaderCGI(self):

    cgiFilename = self.writeCGI(BROKEN_HEADER_CGI)
    portnum = self.startServer(cgiFilename)
    url = ('http://localhost:%d/cgi' % (portnum,))
    url = url.encode('ascii')
    agent = client.Agent(reactor)
    d = agent.request('GET', url)
    d.addCallback(discardBody)
    loggedMessages = []
    def addMessage(eventDict):
        loggedMessages.append(log.textFromEventDict(eventDict))
    log.addObserver(addMessage)
    self.addCleanup(log.removeObserver, addMessage)
    def checkResponse(ignored):
        self.assertIn(('ignoring    malformed    CGI    header:    ' + repr('XYZ')), loggedMessages)
    d.addCallback(checkResponse)
    return d
