You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by cu...@apache.org on 2011/12/08 01:58:17 UTC
svn commit: r1211726 - in /avro/trunk: CHANGES.txt lang/py/src/avro/ipc.py
lang/py/test/test_ipc.py
Author: cutting
Date: Thu Dec 8 00:58:17 2011
New Revision: 1211726
URL: http://svn.apache.org/viewvc?rev=1211726&view=rev
Log:
AVRO-953. Python: Permit users to override HTTP path in RPC. Contributed by Craig Landry.
Modified:
avro/trunk/CHANGES.txt
avro/trunk/lang/py/src/avro/ipc.py
avro/trunk/lang/py/test/test_ipc.py
Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1211726&r1=1211725&r2=1211726&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Thu Dec 8 00:58:17 2011
@@ -11,6 +11,9 @@ Avro 1.6.2 (unreleased)
AVRO-963. Java: Permit compiler template directory to be
overridden by Maven plugins. (George Fletcher via cutting)
+ AVRO-953. Python: Permit users to override HTTP path in RPC.
+ (Craig Landry via cutting)
+
BUG FIXES
AVRO-962. Java: Fix Maven plugin to support string type override.
Modified: avro/trunk/lang/py/src/avro/ipc.py
URL: http://svn.apache.org/viewvc/avro/trunk/lang/py/src/avro/ipc.py?rev=1211726&r1=1211725&r2=1211726&view=diff
==============================================================================
--- avro/trunk/lang/py/src/avro/ipc.py (original)
+++ avro/trunk/lang/py/src/avro/ipc.py Thu Dec 8 00:58:17 2011
@@ -439,7 +439,8 @@ class HTTPTransceiver(object):
A simple HTTP-based transceiver implementation.
Useful for clients but not for servers
"""
- def __init__(self, host, port):
+ def __init__(self, host, port, req_resource='/'):
+ self.req_resource = req_resource
self.conn = httplib.HTTPConnection(host, port)
self.conn.connect()
@@ -451,6 +452,7 @@ class HTTPTransceiver(object):
def set_conn(self, new_conn):
self._conn = new_conn
conn = property(lambda self: self._conn, set_conn)
+ req_resource = '/'
def transceive(self, request):
self.write_framed_message(request)
@@ -466,14 +468,13 @@ class HTTPTransceiver(object):
def write_framed_message(self, message):
req_method = 'POST'
- req_resource = '/'
req_headers = {'Content-Type': 'avro/binary'}
req_body_buffer = FramedWriter(StringIO())
req_body_buffer.write_framed_message(message)
req_body = req_body_buffer.writer.getvalue()
- self.conn.request(req_method, req_resource, req_body, req_headers)
+ self.conn.request(req_method, self.req_resource, req_body, req_headers)
def close(self):
self.conn.close()
Modified: avro/trunk/lang/py/test/test_ipc.py
URL: http://svn.apache.org/viewvc/avro/trunk/lang/py/test/test_ipc.py?rev=1211726&r1=1211725&r2=1211726&view=diff
==============================================================================
--- avro/trunk/lang/py/test/test_ipc.py (original)
+++ avro/trunk/lang/py/test/test_ipc.py Thu Dec 8 00:58:17 2011
@@ -21,11 +21,18 @@ import unittest
# This test does import this code, to make sure it at least passes
# compilation.
-import avro.ipc
+from avro import ipc
class TestIPC(unittest.TestCase):
def test_placeholder(self):
pass
+ def test_server_with_path(self):
+ client_with_custom_path = ipc.HTTPTransceiver('dummyserver.net', 80, '/service/article')
+ self.assertEqual('/service/article', client_with_custom_path.req_resource)
+
+ client_with_default_path = ipc.HTTPTransceiver('dummyserver.net', 80)
+ self.assertEqual('/', client_with_default_path.req_resource)
+
if __name__ == '__main__':
unittest.main()