def test_connection_is_closed_on_redirect(self):
     protocol = RedirectAwareProberProtocol()
     protocol.factory = FakeFactory('http://foo.bar/')
     protocol.makeConnection(FakeTransport())
     protocol.dataReceived("HTTP/1.1 301 Moved Permanently\r\n"
                           "Location: http://foo.baz/\r\n"
                           "Length: 0\r\n"
                           "\r\n")
     self.assertEqual('http://foo.baz/', protocol.factory.redirectedTo)
     self.failUnless(protocol.transport.disconnecting)
 def test_connection_is_closed_on_redirect(self):
     protocol = RedirectAwareProberProtocol()
     protocol.factory = FakeFactory('http://foo.bar/')
     protocol.makeConnection(FakeTransport())
     protocol.dataReceived(
         "HTTP/1.1 301 Moved Permanently\r\n"
         "Location: http://foo.baz/\r\n"
         "Length: 0\r\n"
         "\r\n")
     self.assertEqual('http://foo.baz/', protocol.factory.redirectedTo)
     self.failUnless(protocol.transport.disconnecting)
    def test_prober_user_agent(self):
        protocol = RedirectAwareProberProtocol()

        orig_sendHeader = protocol.sendHeader
        headers = {}

        def mySendHeader(header, value):
            orig_sendHeader(header, value)
            headers[header] = value

        protocol.sendHeader = mySendHeader

        protocol.factory = FakeFactory('http://foo.bar/')
        protocol.makeConnection(FakeTransport())
        self.assertEquals('Launchpad Mirror Prober ( https://launchpad.net/ )',
                          headers['User-Agent'])
    def test_prober_user_agent(self):
        protocol = RedirectAwareProberProtocol()

        orig_sendHeader = protocol.sendHeader
        headers = {}

        def mySendHeader(header, value):
            orig_sendHeader(header, value)
            headers[header] = value

        protocol.sendHeader = mySendHeader

        protocol.factory = FakeFactory('http://foo.bar/')
        protocol.makeConnection(FakeTransport())
        self.assertEquals(
            'Launchpad Mirror Prober ( https://launchpad.net/ )',
            headers['User-Agent'])