Changeset 561dd26
- Timestamp:
- Jan 9, 2021, 4:50:11 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 108f98b2
- Parents:
- ece0e80
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/worker.cfa
rece0e80 r561dd26 63 63 } 64 64 65 printf("=== Request for file %.*s ===\n", (int)name_size, file); 65 if(0 == strncmp(file, "plaintext", min(name_size, sizeof("plaintext") ))) { 66 printf("=== Request for /plaintext ===\n"); 66 67 67 // Get the fd from the file cache 68 int ans_fd; 69 size_t count; 70 [ans_fd, count] = get_file( file, name_size ); 68 char text[] = "Hello, World!\n"; 71 69 72 // If we can't find the file, return 404 73 if( ans_fd < 0 ) { 74 printf("=== File Not Found ===\n"); 75 answer_error(fd, E404); 76 continue REQUEST; 70 // Send the header 71 answer_plain(fd, text, sizeof(text)); 72 } 73 else { 74 printf("=== Request for file %.*s ===\n", (int)name_size, file); 75 76 // Get the fd from the file cache 77 int ans_fd; 78 size_t count; 79 [ans_fd, count] = get_file( file, name_size ); 80 81 // If we can't find the file, return 404 82 if( ans_fd < 0 ) { 83 printf("=== File Not Found ===\n"); 84 answer_error(fd, E404); 85 continue REQUEST; 86 } 87 88 // Send the header 89 answer_header(fd, count); 90 91 // Send the desired file 92 sendfile( this.pipe, fd, ans_fd, count); 77 93 } 78 94 79 // Send the header 80 answer_header(fd, count); 81 82 // Send the desired file 83 sendfile( this.pipe, fd, ans_fd, count); 84 85 printf("=== File sent ===\n"); 95 printf("=== Answer sent ===\n"); 86 96 } 87 97 }
Note: See TracChangeset
for help on using the changeset viewer.