Overview
Comment: | Updated to support the HEAD HTTP method |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5a054ee091543db480d8bdf83e8d9f9e |
User & Date: | rkeene on 2014-02-11 07:43:06 |
Original Comment: | Updated to support the HEAD HTTP method5~ |
Other Links: | manifest | tags |
Context
2014-02-11
| ||
08:11 | Added ETag check-in: 63a88bc1bc user: rkeene tags: trunk | |
07:43 | Updated to support the HEAD HTTP method check-in: 5a054ee091 user: rkeene tags: trunk | |
05:53 | Removed unneeded assignment check-in: 8cb189c633 user: rkeene tags: trunk | |
Changes
Modified filed.c from [8c74e1e76e] to [93c05a56c1].
︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | + + + + + + | /* Request variables */ struct filed_http_request { /** Buffers **/ struct filed_fileinfo fileinfo; char tmpbuf[1010]; /** HTTP Request information **/ /*** Type of request (HEAD or GET) ***/ enum { FILED_REQUEST_METHOD_GET, FILED_REQUEST_METHOD_HEAD } method; /*** Path being requested ***/ char path[FILED_PATH_BUFFER_SIZE]; struct { struct { int present; off_t offset; /*** Range start ***/ |
︙ | |||
99 100 101 102 103 104 105 106 107 108 109 110 111 112 | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | + | time_t endtime; off_t req_offset; off_t req_length; off_t sent_length; off_t file_length; char ip[128]; int port; int method; }; /* Global variables */ /** Open File cache **/ struct filed_fileinfo *filed_fileinfo_fdcache = NULL; unsigned int filed_fileinfo_fdcache_size = 0; |
︙ | |||
243 244 245 246 247 248 249 250 251 252 253 254 255 256 | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | + | # define filed_log_msg_debug(x, ...) /**/ # endif /* Initialize logging thread */ static void *filed_logging_thread(void *arg_p) { struct filed_logging_thread_args *arg; struct filed_log_entry *curr, *prev; const char *method; time_t now; FILE *fp; arg = arg_p; fp = arg->fp; |
︙ | |||
276 277 278 279 280 281 282 283 284 285 286 | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | + + + + + + + + + + + + - + + | while (curr) { switch (curr->type) { case FILED_LOG_TYPE_MESSAGE: fprintf(fp, "%s", curr->buffer); break; case FILED_LOG_TYPE_TRANSFER: switch (curr->method) { case FILED_REQUEST_METHOD_GET: method="GET"; break; case FILED_REQUEST_METHOD_HEAD: method="HEAD"; break; default: method="<unknown>"; break; } if (curr->endtime == ((time_t) -1)) { curr->endtime = now; } |
︙ | |||
341 342 343 344 345 346 347 348 349 350 351 352 353 354 | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | + | retval->endtime = 0; retval->req_offset = 0; retval->req_length = 0; retval->sent_length = 0; retval->file_length = 0; retval->ip[0] = '\0'; retval->port = -1; retval->method = -1; } return(retval); } static void filed_log_msg(const char *fmt, ...) { struct filed_log_entry *entry; |
︙ | |||
592 593 594 595 596 597 598 | 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | - - - + + + + + + + + + + + | buffer = strchr(buffer, ' '); if (buffer != NULL) { *buffer = '\0'; buffer++; } |
︙ | |||
657 658 659 660 661 662 663 | 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | - + - + - + - + + + + + + + | buffer_st->headers.range.offset = range_start; buffer_st->headers.range.length = range_length; return(buffer_st); } /* Return an error page */ |
︙ | |||
695 696 697 698 699 700 701 | 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 | - + - + - + | return; } request = filed_get_http_request(fp, request); if (request == NULL) { |
︙ | |||
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 | + - + | log->http_code = http_code; log->reason = "OK"; log->starttime = time(NULL); log->req_offset = request->headers.range.offset; log->req_length = request->headers.range.length; log->file_length = fileinfo->len; log->method = request->method; #ifdef FILED_NONBLOCK_HTTP int socket_flags; fd_set rfd, wfd; char sinkbuf[8192]; ssize_t read_ret; FD_ZERO(&rfd); FD_ZERO(&wfd); FD_SET(fd, &rfd); FD_SET(fd, &wfd); socket_flags = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, socket_flags | O_NONBLOCK); #endif sendfile_offset = request->headers.range.offset; sendfile_len = request->headers.range.length; sendfile_sent = 0; |
︙ |