| 201 | } |
| 202 | |
| 203 | long long http_servlet::getFilesize(acl::websocket& in) |
| 204 | { |
| 205 | if (in.read_frame_head() == false) |
| 206 | { |
| 207 | printf("read_frame_head error\r\n"); |
| 208 | return -1; |
| 209 | } |
| 210 | |
| 211 | unsigned char opcode = in.get_frame_opcode(); |
| 212 | switch (opcode) |
| 213 | { |
| 214 | case acl::FRAME_TEXT: |
| 215 | case acl::FRAME_BINARY: |
| 216 | break; |
| 217 | default: |
| 218 | printf("invalid opcode: 0x%0x\r\n", opcode); |
| 219 | return -1; |
| 220 | } |
| 221 | |
| 222 | char buf[256]; |
| 223 | int ret = in.read_frame_data(buf, sizeof(buf) - 1); |
| 224 | if (ret < 0) |
| 225 | { |
| 226 | printf("read_frame_data for filesize error\r\n"); |
| 227 | return -1; |
| 228 | } |
| 229 | buf[ret] = 0; |
| 230 | long long len = atoll(buf); |
| 231 | printf("file size: %lld, buf: %s\r\n", len, buf); |
| 232 | if (len <= 0) |
| 233 | { |
| 234 | printf("invalid file length: %lld\r\n", len); |
| 235 | return -1; |
| 236 | } |
| 237 | |
| 238 | return len; |
| 239 | } |
| 240 | |
| 241 | bool http_servlet::saveFile(acl::websocket& in, const acl::string& filename, |
| 242 | long long len) |
nothing calls this directly
no test coverage detected