| 302 | |
| 303 | template <class T> |
| 304 | bool |
| 305 | get(const std::string &a, std::unique_ptr<io::IO> i, const int64_t l, const T &t, const int64_t ti = 0) |
| 306 | { |
| 307 | using Transaction = HttpTransaction<T>; |
| 308 | struct sockaddr_in socket; |
| 309 | socket.sin_family = AF_INET; |
| 310 | socket.sin_port = 80; |
| 311 | if (!inet_pton(AF_INET, a.c_str(), &socket.sin_addr)) { |
| 312 | Dbg(dbg_ctl, "ats::get Invalid address provided \"%s\".", a.c_str()); |
| 313 | return false; |
| 314 | } |
| 315 | TSVConn vconn = TSHttpConnect(reinterpret_cast<sockaddr *>(&socket)); |
| 316 | assert(vconn != nullptr); |
| 317 | TSCont contp = TSContCreate(Transaction::handle, nullptr); |
| 318 | assert(contp != nullptr); |
| 319 | Transaction *transaction = new Transaction(vconn, contp, std::move(i), l, t); |
| 320 | TSContDataSet(contp, transaction); |
| 321 | if (ti > 0) { |
| 322 | Dbg(dbg_ctl, "ats::get Setting active timeout to: %" PRId64, ti); |
| 323 | transaction->timeout(ti); |
| 324 | } |
| 325 | return true; |
| 326 | } |
| 327 | |
| 328 | template <class T> |
| 329 | bool |
no test coverage detected