| 220 | } |
| 221 | |
| 222 | static void ServeFile(WebDebugConnection * connection, const char * filename) |
| 223 | { |
| 224 | FILE * fh = fopen(filename, "rb"); |
| 225 | if (!fh) |
| 226 | { |
| 227 | Generate404(connection, filename); |
| 228 | return; |
| 229 | } |
| 230 | |
| 231 | connection->BeginResponse(200, -1, GetContentTypeForFilename(filename)); |
| 232 | |
| 233 | static const size_t kBufSize = 1024; |
| 234 | size_t len_read; |
| 235 | char buf[kBufSize]; |
| 236 | do |
| 237 | { |
| 238 | len_read = fread(buf, 1, kBufSize, fh); |
| 239 | if (len_read > 0) |
| 240 | connection->Write(buf, len_read); |
| 241 | } |
| 242 | while (len_read == kBufSize); |
| 243 | |
| 244 | connection->EndResponse(); |
| 245 | fclose(fh); |
| 246 | } |
| 247 | |
| 248 | bool ServeResource(WebDebugConnection * connection, const char * resource_path) |
| 249 | { |
no test coverage detected