| 32 | } |
| 33 | |
| 34 | bool http_servlet::doPost(acl::HttpServletRequest& req, |
| 35 | acl::HttpServletResponse& res) |
| 36 | { |
| 37 | // �����Ҫ http session ���ƣ��������ע�ͣ�����Ҫ��֤ |
| 38 | // �� master_service.cpp �ĺ��� thread_on_read �����õ� |
| 39 | // memcached ������������ |
| 40 | /* |
| 41 | const char* sid = req.getSession().getAttribute("sid"); |
| 42 | if (*sid == 0) |
| 43 | req.getSession().setAttribute("sid", "xxxxxx"); |
| 44 | sid = req.getSession().getAttribute("sid"); |
| 45 | */ |
| 46 | |
| 47 | // �����Ҫȡ������� cookie �������ע�� |
| 48 | /* |
| 49 | const char* mycookie = req.getCookieValue("mycookie"); |
| 50 | if (mycookie == NULL) |
| 51 | res.addCookie("mycookie", "{xxx}"); |
| 52 | */ |
| 53 | |
| 54 | const char* param1 = req.getParameter("name1"); |
| 55 | const char* param2 = req.getParameter("name2"); |
| 56 | |
| 57 | // ���� xml ��ʽ�������� |
| 58 | acl::xml1 body; |
| 59 | body.get_root() |
| 60 | .add_child("root", true) |
| 61 | .add_child("params", true) |
| 62 | .add_child("param", true) |
| 63 | .add_attr("name1", param1 ? param1 : "null") |
| 64 | .get_parent() |
| 65 | .add_child("param", true) |
| 66 | .add_attr("name2", param2 ? param2 : "null"); |
| 67 | acl::string buf; |
| 68 | body.build_xml(buf); |
| 69 | |
| 70 | //printf(">>>buf: %s\r\n", buf.c_str()); |
| 71 | |
| 72 | bool keep_alive = req.isKeepAlive(); |
| 73 | |
| 74 | res.setContentType("text/xml; charset=utf-8") // ������Ӧ�ַ��� |
| 75 | .setKeepAlive(keep_alive) // �����Ƿֳ����� |
| 76 | .setContentLength(buf.size()) |
| 77 | .setChunkedTransferEncoding(true); // ���� chunk ���䷽ʽ |
| 78 | |
| 79 | // ���� http ��Ӧ�壬��Ϊ������ chunk ����ģʽ��������Ҫ�����һ�� |
| 80 | // res.write ������������Ϊ 0 �Ա�ʾ chunk �������ݽ��� |
| 81 | bool ret = res.write(buf) && res.write(NULL, 0) && keep_alive; |
| 82 | //printf(">>>write %s\r\n", ret ? "ok":"error"); |
| 83 | return ret; |
| 84 | } |
nothing calls this directly
no test coverage detected