| 30 | } |
| 31 | |
| 32 | virtual bool doPost(HttpServletRequest& req, HttpServletResponse& res) |
| 33 | { |
| 34 | const char* sid = req.getSession().getAttribute("sid"); |
| 35 | if (*sid == 0) |
| 36 | req.getSession().setAttribute("sid", "xxxxxx"); |
| 37 | sid = req.getSession().getAttribute("sid"); |
| 38 | |
| 39 | const char* cookie1 = req.getCookieValue("name1"); |
| 40 | const char* cookie2 = req.getCookieValue("name2"); |
| 41 | |
| 42 | // ���� HTTP ��Ӧͷ |
| 43 | res.addCookie("name1", "value1"); |
| 44 | res.addCookie("name2", "value2", ".test.com", "/", 3600 * 24); |
| 45 | |
| 46 | // ������Ӧͷ��״̬�� |
| 47 | //res.setStatus(200); |
| 48 | |
| 49 | // ���ַ�ʽ�����������ַ��� |
| 50 | if (0) |
| 51 | res.setContentType("text/xml; charset=gb2312"); |
| 52 | else |
| 53 | { |
| 54 | res.setContentType("text/xml"); |
| 55 | res.setCharacterEncoding("gb2312"); |
| 56 | } |
| 57 | |
| 58 | const char* param1 = req.getParameter("name1"); |
| 59 | const char* param2 = req.getParameter("name2"); |
| 60 | |
| 61 | // ���� xml ��ʽ�������� |
| 62 | xml1 body; |
| 63 | body.get_root().add_child("root", true) |
| 64 | .add_child("sessions", true) |
| 65 | .add_child("session", true) |
| 66 | .add_attr("sid", sid ? sid : "null") |
| 67 | .get_parent() |
| 68 | .get_parent() |
| 69 | .add_child("cookies", true) |
| 70 | .add_child("cookie", true) |
| 71 | .add_attr("name1", cookie1 ? cookie1 : "null") |
| 72 | .get_parent() |
| 73 | .add_child("cookie", true) |
| 74 | .add_attr("name2", cookie2 ? cookie2 : "null") |
| 75 | .get_parent() |
| 76 | .get_parent() |
| 77 | .add_child("params", true) |
| 78 | .add_child("param", true) |
| 79 | .add_attr("name1", param1 ? param1 : "null") |
| 80 | .get_parent() |
| 81 | .add_child("param", true) |
| 82 | .add_attr("name2", param2 ? param2 : "null"); |
| 83 | |
| 84 | string buf; |
| 85 | body.build_xml(buf); |
| 86 | |
| 87 | // ���� http ��Ӧͷ |
| 88 | if (res.sendHeader() == false) |
| 89 | return false; |
nothing calls this directly
no test coverage detected