summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--main.c25
2 files changed, 23 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1a94556
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
1main
2
diff --git a/main.c b/main.c
index 5395ab2..da67e45 100644
--- a/main.c
+++ b/main.c
@@ -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 }
..