| 15 | static std::atomic_llong counter = ATOMIC_VAR_INIT(0); |
| 16 | |
| 17 | int main(int argc, char** argv) |
| 18 | { |
| 19 | (void) argc; |
| 20 | (void) argv; |
| 21 | |
| 22 | auto service = IOThreadTcpService::Create(); |
| 23 | service->startWorkerThread(2); |
| 24 | |
| 25 | auto connector = brynet::net::AsyncConnector::Create(); |
| 26 | connector->startWorkerThread(); |
| 27 | |
| 28 | HttpRequest request; |
| 29 | request.setMethod(HttpRequest::HTTP_METHOD::HTTP_METHOD_GET); |
| 30 | request.setUrl("/"); |
| 31 | request.addHeadValue("Host", "www.baidu.com"); |
| 32 | |
| 33 | HttpQueryParameter p; |
| 34 | p.add("key", "DCD9C36F1F54A96F707DFBE833600167"); |
| 35 | p.add("appid", "929390"); |
| 36 | p.add("ticket", |
| 37 | "140000006FC57764C95D45085373F104" |
| 38 | "01001001359F745C1800000001000000020000009" |
| 39 | "DACD3DE1202A8C0431E100003000000B200000032" |
| 40 | "000000040000005373F104010010016E2E0E009D" |
| 41 | "ACD3DE1202A8C000000000AAA16F5C2A518B5C" |
| 42 | "0100FC96040000000000061129B849B0397DD" |
| 43 | "62E0B1B0373451EC08E1BAB70FC18E21094F" |
| 44 | "C5F4674EDD50226ABB33D71C601B8E65542F" |
| 45 | "B9A9F48BFF87AC30904D272FAD5F15CD2D5428" |
| 46 | "D44827BA58A45886119D6244D672A0C1909C5D" |
| 47 | "7BD9096D96EB8BAC30E006BE6D405E5B25659" |
| 48 | "CF3D343C9627078C5FD4CE0120D80DDB2FA09E76111143F132CA0B"); |
| 49 | request.setQuery(p.getResult()); |
| 50 | |
| 51 | std::string requestStr = request.getResult(); |
| 52 | |
| 53 | for (size_t i = 0; i < 1; i++) |
| 54 | { |
| 55 | // ConnectOption::WithAddr("23.73.140.64", 80), |
| 56 | wrapper::HttpConnectionBuilder() |
| 57 | .WithConnector(connector) |
| 58 | .WithService(service) |
| 59 | .WithAddr("14.215.177.39", 80) |
| 60 | .WithTimeout(std::chrono::seconds(10)) |
| 61 | .WithFailedCallback([]() { |
| 62 | std::cout << "connect failed" << std::endl; |
| 63 | }) |
| 64 | .WithMaxRecvBufferSize(1000) |
| 65 | .WithEnterCallback([requestStr](const HttpSession::Ptr& session, HttpSessionHandlers& handlers) { |
| 66 | (void) session; |
| 67 | std::cout << "connect success" << std::endl; |
| 68 | session->send(requestStr); |
| 69 | handlers.setHttpBodyCallback([](const HTTPParser& httpParser, |
| 70 | const HttpSession::Ptr& session, |
| 71 | const char* body, |
| 72 | size_t length) { |
| 73 | (void) httpParser; |
| 74 | (void) session; |
nothing calls this directly
no test coverage detected