[ https://issues.apache.org/jira/browse/THRIFT-5090?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jens Geyer updated THRIFT-5090: ------------------------------- Summary: error "TConnectedClient processing exception: Expected control char, got '/'" when a string argument contains a slash and JSON is used (was: Error with slash in argument) > error "TConnectedClient processing exception: Expected control char, got '/'" > when a string argument contains a slash and JSON is used > -------------------------------------------------------------------------------------------------------------------------------------- > > 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.10.0, 0.11.0, 0.12.0, 0.13.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 > Priority: Major > > When calling a method from php THttpClient / TJSONProtocol client to a C ++ > server, an error occurs if the argument of the function contains a "/" slash. > php client displays an error:: > {noformat} > PHP Fatal error: Uncaught Thrift\Exception\TTransportException: THttpClient: > Could not connect to localhost:9090 in > /usr/lib/php/Thrift/Transport/THttpClient.php:28 > {noformat} > C++ server displays an error:: > {noformat} > Thrift: Thu Feb 13 10:22:23 2020 TConnectedClient processing exception: > Expected control char, got '/'. > {noformat} > If the request from JS (TXHRTransport / TJSONProtocol) to the C ++ server, > everything is fine > If the request from php (THttpClient / TJSONProtocol) to python THttpServer / > TJSONProtocol everything is fine > > *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:9090 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)