--- /dev/null
+/*\r
+ * Copyright (c) 2019, The Jaeger Authors\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include "jaegertracing/utils/HTTPTransporter.h"\r
+#include <thrift/protocol/TBinaryProtocol.h>\r
+#include <thrift/protocol/TProtocol.h>\r
+\r
+namespace jaegertracing {\r
+namespace utils {\r
+\r
+HTTPTransporter::HTTPTransporter(const net::URI& endpoint, int maxPacketSize)\r
+ : Transport(maxPacketSize == 0 ? kHttpPacketMaxLength : maxPacketSize)\r
+ , _buffer(new apache::thrift::transport::TMemoryBuffer(_maxPacketSize))\r
+ , _serverAddr(net::IPAddress::v4(endpoint._host, endpoint._port))\r
+ , _httpClient(new ::apache::thrift::transport::THttpClient(\r
+ _buffer, endpoint._host, endpoint._path + "?format=jaeger.thrift"))\r
+{\r
+ using TProtocolFactory = apache::thrift::protocol::TProtocolFactory;\r
+ using TBinaryProtocolFactory =\r
+ apache::thrift::protocol::TBinaryProtocolFactory;\r
+\r
+ _socket.open(AF_INET, SOCK_STREAM);\r
+ _socket.connect(_serverAddr);\r
+ std::shared_ptr<TProtocolFactory> protocolFactory(\r
+ new TBinaryProtocolFactory());\r
+ _protocol = protocolFactory->getProtocol(_httpClient);\r
+}\r
+\r
+} // namespace utils\r
+} // namespace jaegertracing\r