From 727d67dcfad44784b1ef552d4744f739a8fe7d3c Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Thu, 2 Sep 2010 01:00:19 +0000 Subject: [PATCH] THRIFT-721. py: THttpClient ignores url parameters Respect query string in THttpClient and generated remotes. Also, add an error message on unknown methods. Patch: Thomas Kho git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991786 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/generate/t_py_generator.cc | 6 ++++++ lib/py/src/transport/THttpClient.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc index 725573ad..891ba305 100644 --- a/compiler/cpp/src/generate/t_py_generator.cc +++ b/compiler/cpp/src/generate/t_py_generator.cc @@ -1352,6 +1352,8 @@ void t_py_generator::generate_service_remote(t_service* tservice) { " else:" << endl << " port = 80" << endl << " uri = url[2]" << endl << + " if url[4]:" << endl << + " uri += '?%s' % url[4]" << endl << " http = True" << endl << " argi += 2" << endl << endl << @@ -1407,6 +1409,10 @@ void t_py_generator::generate_service_remote(t_service* tservice) { f_remote << endl; } + f_remote << "else:" << endl; + f_remote << " print 'Unrecognized method %s' % cmd" << endl; + f_remote << " sys.exit(1)" << endl; + f_remote << endl; f_remote << "transport.close()" << endl; diff --git a/lib/py/src/transport/THttpClient.py b/lib/py/src/transport/THttpClient.py index 05ca53ab..50269785 100644 --- a/lib/py/src/transport/THttpClient.py +++ b/lib/py/src/transport/THttpClient.py @@ -54,6 +54,8 @@ class THttpClient(TTransportBase): self.port = parsed.port or httplib.HTTPS_PORT self.host = parsed.hostname self.path = parsed.path + if parsed.query: + self.path += '?%s' % parsed.query self.__wbuf = StringIO() self.__http = None self.__timeout = None -- 2.17.1