diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2011-04-16 15:03:11 +0000 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2011-04-16 15:03:11 +0000 |
commit | 1e9f4b75d14a480f461d91452612ced1be7326e0 (patch) | |
tree | 689c26a88f8affb6430f12c8d1c4cd4905b6bbe0 | |
parent | bf02a5c3b9cf297d50f795d272205771c61c2d45 (diff) | |
download | pysendfile-1e9f4b75d14a480f461d91452612ced1be7326e0.tar.gz |
rename headers->header, trailers->trailer
-rw-r--r-- | sendfilemodule.c | 10 | ||||
-rw-r--r-- | test/test_sendfile.py | 24 |
2 files changed, 17 insertions, 17 deletions
diff --git a/sendfilemodule.c b/sendfilemodule.c index 43d1992..4f0c4d8 100644 --- a/sendfilemodule.c +++ b/sendfilemodule.c @@ -63,8 +63,8 @@ method_sendfile(PyObject *self, PyObject *args, PyObject *kwdict) size_t head_len = 0; char * tail = NULL; size_t tail_len = 0; - static char *keywords[] = {"out", "in", "offset", "count", "headers", - "trailers", "flags", NULL}; + static char *keywords[] = {"out", "in", "offset", "count", "header", + "trailer", "flags", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iill|s#s#i:sendfile", keywords, @@ -245,7 +245,7 @@ SendfileMethods[] = { {"sendfile", method_sendfile, METH_VARARGS | METH_KEYWORDS, "sendfile(out, in, offset, nbytes)\n" -"sendfile(out, in, offset, nbytes, headers=None, trailers=None, flags=0)\n" +"sendfile(out, in, offset, nbytes, header=None, trailer=None, flags=0)\n" "\n" "Copy *nbytes* bytes from file descriptor *in* to file descriptor *out*\n" "starting from *offset* and return the number of bytes sent.\n" @@ -256,8 +256,8 @@ SendfileMethods[] = "current position of *in* and the position of *in* is updated. It returns\n" "the same as above with offset being `None`.\n" "\n" -"The second case may be used on Mac OS X and FreeBSD where *headers* and\n" -"*trailers* are arbitrary sequences of buffers that are written before and\n" +"The second case may be used on Mac OS X and FreeBSD where *header* and\n" +"*trailer* are arbitrary sequences of buffers that are written before and\n" "after the data from *in* is written. It returns the same as the first case.\n" "\n" "On Mac OS X and FreeBSD, a value of 0 for *nbytes* specifies to send until\n" diff --git a/test/test_sendfile.py b/test/test_sendfile.py index 7962dd7..e77089e 100644 --- a/test/test_sendfile.py +++ b/test/test_sendfile.py @@ -25,7 +25,7 @@ def _bytes(x): TESTFN = "$testfile" DATA = _bytes("12345abcde" * 1024 * 1024) # 10 Mb HOST = '127.0.0.1' -SUPPORT_HEADERS_TRAILERS = not sys.platform.startswith("linux") +SUPPORT_HEADER_TRAILER = not sys.platform.startswith("linux") class Handler(asynchat.async_chat): @@ -115,15 +115,15 @@ class Server(asyncore.dispatcher, threading.Thread): raise -def sendfile_wrapper(sock, file, offset, nbytes, headers="", trailers=""): +def sendfile_wrapper(sock, file, offset, nbytes, header="", trailer=""): """A higher level wrapper representing how an application is supposed to use sendfile(). """ while 1: try: - if SUPPORT_HEADERS_TRAILERS: + if SUPPORT_HEADER_TRAILER: return sendfile.sendfile(sock, file, offset, nbytes, - headers, trailers) + header, trailer) else: return sendfile.sendfile(sock, file, offset, nbytes) except OSError: @@ -212,15 +212,15 @@ class TestSendfile(unittest.TestCase): else: self.fail("exception not raised") - # --- headers / trailers tests + # --- header / trailer tests - if SUPPORT_HEADERS_TRAILERS: + if SUPPORT_HEADER_TRAILER: - def test_headers(self): + def test_header(self): total_sent = 0 - headers = _bytes("x") * 512 + header = _bytes("x") * 512 sent = sendfile.sendfile(self.sockno, self.fileno, 0, 4096, - headers=headers) + header=header) total_sent += sent offset = 4096 nbytes = 4096 @@ -231,14 +231,14 @@ class TestSendfile(unittest.TestCase): offset += sent total_sent += sent - expected_data = headers + DATA + expected_data = header + DATA self.assertEqual(total_sent, len(expected_data)) self.client.close() self.server.wait() data = self.server.handler_instance.get_data() self.assertEqual(hash(data), hash(expected_data)) - def test_trailers(self): + def test_trailer(self): TESTFN2 = TESTFN + "2" f = open(TESTFN2, 'wb') f.write(_bytes("abcde")) @@ -246,7 +246,7 @@ class TestSendfile(unittest.TestCase): f = open(TESTFN2, 'rb') try: sendfile.sendfile(self.sockno, f.fileno(), 0, 4096, - trailers=_bytes("12345")) + trailer=_bytes("12345")) self.client.close() self.server.wait() data = self.server.handler_instance.get_data() |