| 51 | } |
| 52 | |
| 53 | bool http_servlet::doPost(acl::HttpServletRequest& req, |
| 54 | acl::HttpServletResponse& res) |
| 55 | { |
| 56 | res.setContentType("text/html; charset=utf-8") // ������Ӧ�ַ��� |
| 57 | .setContentEncoding(true) // �����Ƿ�ѹ������ |
| 58 | .setChunkedTransferEncoding(true); // ���� chunk ���䷽ʽ |
| 59 | |
| 60 | const char* ip = req.getLocalAddr(); |
| 61 | if (ip == NULL || *ip == 0) |
| 62 | { |
| 63 | logger_error("getLocalAddr error"); |
| 64 | return false; |
| 65 | } |
| 66 | unsigned short port = req.getLocalPort(); |
| 67 | if (port == 0) |
| 68 | { |
| 69 | logger_error("getLocalPort error"); |
| 70 | return false; |
| 71 | } |
| 72 | |
| 73 | acl::string local_addr; |
| 74 | local_addr << ip << ":" << port; |
| 75 | |
| 76 | printf("getLocalAddr: %s\r\n", local_addr.c_str()); |
| 77 | |
| 78 | acl::string html_file; |
| 79 | html_file << var_cfg_html_path << "/upload.html"; |
| 80 | acl::string buf; |
| 81 | if (acl::ifstream::load(html_file, &buf) == false) |
| 82 | { |
| 83 | logger_error("load %s error %s", |
| 84 | html_file.c_str(), acl::last_serror()); |
| 85 | return doError(req, res); |
| 86 | } |
| 87 | |
| 88 | buf << "<script>g_url='ws://" << local_addr << "/'</script>"; |
| 89 | |
| 90 | // ���� http ��Ӧ�壬��Ϊ������ chunk ����ģʽ��������Ҫ�����һ�� |
| 91 | // res.write ������������Ϊ 0 �Ա�ʾ chunk �������ݽ��� |
| 92 | return res.write(buf) && res.write(NULL, 0); |
| 93 | } |
| 94 | |
| 95 | bool http_servlet::doPing(acl::websocket& in, acl::websocket& out) |
| 96 | { |
nothing calls this directly
no test coverage detected