コード例 #1
0
  def testHTTPErr(self):
    request = URLRequest('http://badhost.local')
    # tell the server to close the connection, if not the run loop won't quit until the socket
    # timesout

    connection = URLConnection.connectionWithRequest(request, self.delegate)
    self.runLoop.run()
    self.assertEqual('didFailWithError', self.delegate.log[0][0])
コード例 #2
0
  def testHTTPURL(self):
    request = URLRequest('http://www.google.com')
    # tell the server to close the connection, if not the run loop won't quit until the socket
    # timesout
    request.HTTPHeaders['connection'] = 'close'
    connection = URLConnection.connectionWithRequest(request, self.delegate)
    self.runLoop.run()

    self.assertEqual('didReceiveResponse', self.delegate.log[0][0])
    self.assertEqual('didFinishLoading', self.delegate.log[-1][0])