| 12 | static double __header_spent, __body_spent, __parse_spent, __build_spent, __response_spent; |
| 13 | |
| 14 | static bool handle_one(http_response& response, bool output) |
| 15 | { |
| 16 | tutorial::AddressBook addr_req; |
| 17 | if (response.read_request(&addr_req) == false) |
| 18 | return false; |
| 19 | |
| 20 | tutorial::AddressBook addr_res; |
| 21 | |
| 22 | for (int i = 0; i < addr_req.person_size(); i++) |
| 23 | { |
| 24 | const tutorial::Person& person = addr_req.person(i); |
| 25 | if (output) |
| 26 | { |
| 27 | printf("person->name: %s\r\n", person.name().c_str()); |
| 28 | printf("person->id: %d\r\n", person.id()); |
| 29 | printf("person->email: %s\r\n", person.has_email() ? |
| 30 | person.email().c_str() : "null"); |
| 31 | } |
| 32 | |
| 33 | tutorial::Person* person2 = addr_res.add_person(); |
| 34 | person2->set_name(person.name().c_str()); |
| 35 | person2->set_email(person.has_email() ? |
| 36 | person.email().c_str() : "null"); |
| 37 | person2->set_id(i); |
| 38 | |
| 39 | // �г����û������е绰 |
| 40 | for (int j = 0; j < person.phone_size(); j++) |
| 41 | { |
| 42 | const tutorial::Person::PhoneNumber& phone = person.phone(j); |
| 43 | if (output) |
| 44 | printf("\tphone number: %s\r\n", phone.number().c_str()); |
| 45 | |
| 46 | tutorial::Person::PhoneNumber* phone2 = person2->add_phone(); |
| 47 | phone2->set_number(phone.number().c_str()); |
| 48 | } |
| 49 | if (output) |
| 50 | printf("------------------------------------------\r\n"); |
| 51 | } |
| 52 | |
| 53 | return response.send_response(addr_res); |
| 54 | } |
| 55 | |
| 56 | static void handle_client(acl::socket_stream* client) |
| 57 | { |
no test coverage detected
searching dependent graphs…