def testPlainXml(self): client = HttpClient() self.response = """HTTP/1.0 200 OK\r\nContent-Type: text/xml\r\n\r\n<xml/>""" gen = client.httpGet(hostname='localhost', port=80, path='/', arguments={}) headers, body = retval(gen) self.assertEquals('<xml/>', lxmltostring(body)) self.assertEquals(['HTTP/1.0 200 OK', 'Content-Type: text/xml'], headers.split(CRLF))
def testHttpsGet(self): client = HttpClient() self.response = """HTTP/1.0 200 OK\r\n\r\nother-data""" gen = client.httpsGet(hostname='localhost', port=443, path='/', arguments={}, parse=False) headers, body = retval(gen) self.assertEquals('other-data', body) self.assertEquals(['HTTP/1.0 200 OK'], headers.split(CRLF))
def testHttpPost(self): client = HttpClient() self.response = b"""HTTP/1.0 200 OK\r\n\r\nother-data""" gen = client.httpPost(hostname='localhost', port=80, path='/', data='data', parse=False) headers, body = retval(gen) self.assertEqual('other-data', body) self.assertEqual(['HTTP/1.0 200 OK'], headers.split(CRLF))