���� text/xml ������
| 103 | |
| 104 | // ���� text/xml ������ |
| 105 | bool do_xml(http_response& res, const char* req_charset, string& err) { |
| 106 | xml1 body; |
| 107 | if (res.get_body(body, local_charset_) == false) { |
| 108 | err += "get_body error"; |
| 109 | return false; |
| 110 | } |
| 111 | xml_node* node = body.first_node(); |
| 112 | while (node) { |
| 113 | const char* tag = node->tag_name(); |
| 114 | const char* name = node->attr_value("name"); |
| 115 | const char* pass = node->attr_value("pass"); |
| 116 | printf(">>tag: %s, name: %s, pass: %s\r\n", |
| 117 | tag ? tag : "null", |
| 118 | name ? name : "null", |
| 119 | pass ? pass : "null"); |
| 120 | node = body.next_node(); |
| 121 | } |
| 122 | |
| 123 | // ������Ӧͷ�ֶ� |
| 124 | http_header& header = res.response_header(); |
| 125 | string ctype("text/xml"); |
| 126 | if (req_charset) { |
| 127 | ctype << "; charset=" << req_charset; |
| 128 | header.set_content_type(ctype); |
| 129 | } else { |
| 130 | header.set_content_type(ctype); |
| 131 | } |
| 132 | |
| 133 | printf(">>ctype: %s\r\n", ctype.c_str()); |
| 134 | |
| 135 | // ������Ӧ�����ݣ���������Ӧ������ |
| 136 | string buf; |
| 137 | body.build_xml(buf); |
| 138 | |
| 139 | // ������Ӧ������ |
| 140 | return response_body(res, buf, req_charset); |
| 141 | } |
| 142 | |
| 143 | // ���� text/json ���� |
| 144 | bool do_json(http_response& res, const char* req_charset, string& err) { |
nothing calls this directly
no test coverage detected