From c7b65d1123d8bbfcb55c3791bd1ddbd7dec07756 Mon Sep 17 00:00:00 2001 From: Emil Mikulic Date: Sun, 1 May 2011 18:15:56 +1000 Subject: [PATCH] Test for HEAD method. --- devel/test.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/devel/test.py b/devel/test.py index 58007fa..169f225 100755 --- a/devel/test.py +++ b/devel/test.py @@ -15,8 +15,8 @@ class Conn: self.s.connect(("0.0.0.0", self.port)) # connect throws socket.error on connection refused - def get(self, url, http_ver="1.0", endl="\n", req_hdrs={}): - req = "GET "+url + def get(self, url, http_ver="1.0", endl="\n", req_hdrs={}, method="GET"): + req = method+" "+url if http_ver is not None: req += " HTTP/"+http_ver req += endl @@ -171,6 +171,13 @@ class TestFileGet(TestHelper): self.assertEquals(hdrs["Content-Type"], "image/jpeg") self.assertEquals(body, self.data) + def test_file_head(self): + resp = Conn().get(self.url, method="HEAD") + status, hdrs, body = parse(resp) + self.assertContains(status, "200 OK") + self.assertEquals(hdrs["Content-Length"], str(self.datalen)) + self.assertEquals(hdrs["Content-Type"], "image/jpeg") + if __name__ == '__main__': setUpModule() unittest.main()