diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -223,19 +223,36 @@ void * next_customer(size_t new_socket) { | |||
223 | while(1) { | 223 | while(1) { |
224 | size_t size_remaining = (size_t) output_buffer_length - (p - output_buffer) - 1; | 224 | size_t size_remaining = (size_t) output_buffer_length - (p - output_buffer) - 1; |
225 | printf("%ld remaining.\n", size_remaining); fflush(stdout); | 225 | printf("%ld remaining.\n", size_remaining); fflush(stdout); |
226 | if(size_remaining <= 0) | 226 | |
227 | if(size_remaining <= 0) { | ||
228 | verbose("> not even the boundary would fit in that what is left.\n"); | ||
227 | break; | 229 | break; |
230 | } | ||
228 | 231 | ||
229 | p = (char *) memchr( | 232 | p = (char *) memchr( |
230 | (void *) p, '-', size_remaining); | 233 | (void *) p, '-', size_remaining); |
231 | 234 | ||
235 | |||
236 | if(!p) { | ||
237 | verbose("> no further minus found.\n"); | ||
238 | break; | ||
239 | } | ||
240 | |||
241 | end = p; | ||
242 | if(end[-1] == '\n') end--; | ||
243 | if(end[-1] == '\r') end--; | ||
232 | p += strspn(p, "-"); | 244 | p += strspn(p, "-"); |
233 | 245 | ||
234 | if(0 >= strcmp(p, http_header.boundary)) { | 246 | if(0 == strncmp(p, http_header.boundary, http_header.boundary_size)) { |
235 | verbose("content ends here"); | 247 | verbose("> Content ends here, size of the last file is %ld\n", end - start); |
248 | |||
249 | fwrite(start, 20, 1, stdout); | ||
250 | puts(" <[first 20 bytes]\n"); | ||
251 | fwrite(end - 20, 20, 1, stdout); | ||
252 | puts(" <[last 20 bytes]\n"); | ||
236 | break; | 253 | break; |
237 | } else { | 254 | } else { |
238 | printf("[%ld] kack: %c\n", size_remaining, p[0]); fflush(stdout); | 255 | // printf("[%ld] kack: %c\n", size_remaining, p[0]); fflush(stdout); |
239 | p = p + 1; | 256 | p = p + 1; |
240 | } | 257 | } |
241 | } | 258 | } |