Test for HEAD method.

This commit is contained in:
Emil Mikulic 2011-05-01 18:15:56 +10:00
parent d916f760b8
commit c7b65d1123

View File

@ -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()