Changeset 2859 in MondoRescue for branches/2.2.9/mindi-busybox/networking
- Timestamp:
- Jul 26, 2011, 1:25:42 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/networking/wget.c
r2725 r2859 447 447 static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd) 448 448 { 449 char buf[ 512];449 char buf[4*1024]; /* made bigger to speed up local xfers */ 450 450 #if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT 451 451 # if ENABLE_FEATURE_WGET_TIMEOUT … … 456 456 polldata.fd = fileno(dfp); 457 457 polldata.events = POLLIN | POLLPRI; 458 ndelay_on(polldata.fd);459 458 #endif 460 459 progress_meter(PROGRESS_START); … … 465 464 /* Loops only if chunked */ 466 465 while (1) { 466 467 #if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT 468 ndelay_on(polldata.fd); 469 #endif 467 470 while (1) { 468 471 int n; … … 494 497 } 495 498 #endif 499 /* fread internally uses read loop, which in our case 500 * is usually exited when we get EAGAIN. 501 * In this case, libc sets error marker on the stream. 502 * Need to clear it before next fread to avoid possible 503 * rare false positive ferror below. Rare because usually 504 * fread gets more than zero bytes, and we don't fall 505 * into if (n <= 0) ... 506 */ 507 clearerr(dfp); 508 errno = 0; 496 509 n = safe_fread(buf, rdsz, dfp); 510 /* man fread: 511 * If error occurs, or EOF is reached, the return value 512 * is a short item count (or zero). 513 * fread does not distinguish between EOF and error. 514 */ 497 515 if (n <= 0) { 498 if (ferror(dfp)) { 499 /* perror will not work: ferror doesn't set errno */ 500 bb_error_msg_and_die(bb_msg_read_error); 501 } 502 break; 516 #if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT 517 if (errno == EAGAIN) /* poll lied, there is no data? */ 518 continue; /* yes */ 519 #endif 520 if (ferror(dfp)) 521 bb_perror_msg_and_die(bb_msg_read_error); 522 break; /* EOF, not error */ 503 523 } 524 504 525 xwrite(output_fd, buf, n); 505 526 #if ENABLE_FEATURE_WGET_STATUSBAR … … 507 528 progress_meter(PROGRESS_BUMP); 508 529 #endif 509 if (G.got_clen) 530 if (G.got_clen) { 510 531 G.content_len -= n; 511 } 532 if (G.content_len == 0) 533 break; 534 } 535 } 536 #if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT 537 ndelay_off(polldata.fd); 538 #endif 512 539 513 540 if (!G.chunked) … … 707 734 target.host, user_agent); 708 735 736 /* Ask server to close the connection as soon as we are done 737 * (IOW: we do not intend to send more requests) 738 */ 739 fprintf(sfp, "Connection: close\r\n"); 740 709 741 #if ENABLE_FEATURE_WGET_AUTHENTICATION 710 742 if (target.user) { … … 720 752 if (G.beg_range) 721 753 fprintf(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range); 754 722 755 #if ENABLE_FEATURE_WGET_LONG_OPTIONS 723 756 if (extra_headers) … … 726 759 if (opt & WGET_OPT_POST_DATA) { 727 760 char *estr = URL_escape(post_data); 728 fprintf(sfp, "Content-Type: application/x-www-form-urlencoded\r\n"); 729 fprintf(sfp, "Content-Length: %u\r\n" "\r\n" "%s", 730 (int) strlen(estr), estr); 731 /*fprintf(sfp, "Connection: Keep-Alive\r\n\r\n");*/ 732 /*fprintf(sfp, "%s\r\n", estr);*/ 761 fprintf(sfp, 762 "Content-Type: application/x-www-form-urlencoded\r\n" 763 "Content-Length: %u\r\n" 764 "\r\n" 765 "%s", 766 (int) strlen(estr), estr 767 ); 733 768 free(estr); 734 769 } else 735 770 #endif 736 { /* If "Connection:" is needed, document why */737 fprintf(sfp, /* "Connection: close\r\n" */"\r\n");771 { 772 fprintf(sfp, "\r\n"); 738 773 } 739 774
Note:
See TracChangeset
for help on using the changeset viewer.