Thrift Bugger created THRIFT-5090: ------------------------------------- Summary: Error with slash in argument Key: THRIFT-5090 URL: https://issues.apache.org/jira/browse/THRIFT-5090 Project: Thrift Issue Type: Bug Components: C++ - Library, PHP - Library Affects Versions: 0.13.0, 0.12.0, 0.11.0, 0.10.0 Environment: Linux 4.15.0-74-generic #83~16.04.1-Ubuntu SMP Wed Dec 18 04:56:23 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux Reporter: Thrift Bugger
sample.thrift: {code:java} service Bug { void bug(1:string val), } {code} {code:java} thrift -r --gen php sample.thrift thrift -r --gen cpp sample.thrift {code} *client on php* {code:php} <?php $GLOBALS['THRIFT_ROOT'] = '/usr/lib/php'; require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/ClassLoader/ThriftClassLoader.php'; use Thrift\ClassLoader\ThriftClassLoader; $GEN_DIR = 'gen-php'; $loader = new ThriftClassLoader(); $loader->registerNamespace( 'Thrift', $GLOBALS['THRIFT_ROOT'] ); $loader->register(); use Thrift\Protocol\TJSONProtocol; use Thrift\Transport\THttpClient; use Thrift\Transport\TBufferedTransport; require_once $GEN_DIR.'/Bug.php'; require_once $GEN_DIR.'/Types.php'; $socket = new THttpClient( '127.0.0.1', 9090 ); $transport = new TBufferedTransport( $socket, 1024, 1024 ); $protocol = new TJSONProtocol( $transport ); $client = new BugClient( $protocol ); $client->bug( 'str' ); // ok $client->bug( 'str with / slash' ); // PHP Fatal error // PHP Fatal error: Uncaught Thrift\Exception\TTransportException: THttpClient: Could not connect to localhost:9095 in /usr/lib/php/Thrift/Transport/THttpClient.php:28 {code} *server on c++* {code:java} #include "gen-cpp/Bug.h" #include <iostream> #include <thrift/protocol/TJSONProtocol.h> #include <thrift/server/TThreadedServer.h> #include <thrift/transport/THttpServer.h> #include <thrift/transport/TServerSocket.h> using namespace ::apache::thrift; using namespace ::apache::thrift::protocol; using namespace ::apache::thrift::transport; using namespace ::apache::thrift::server; using namespace ::apache::thrift::async; using boost::shared_ptr; class BugHandler : virtual public BugIf { void bug(const std::string& val) { std::cout << val << std::endl; } }; int main(int argc, char ** argv) { shared_ptr<BugHandler> bug( new BugHandler() ); shared_ptr<TProcessor> processor( new BugProcessor(bug) ); shared_ptr<TTransportFactory> transportFactory( new THttpServerTransportFactory() ); shared_ptr<TProtocolFactory> protocolFactory( new TJSONProtocolFactory() ); shared_ptr<TServerTransport> serverTransport( new TServerSocket( 9090 ) ); shared_ptr<TThreadedServer> server( new TThreadedServer( processor, serverTransport, transportFactory, protocolFactory ) ); server->serve(); return 0; } {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)