Line 0
Link Here
|
|
|
1 |
--- scripts/squid_redirect-nodata.orig |
2 |
+++ scripts/squid_redirect-nodata |
3 |
@@ -31,7 +31,7 @@ use bytes; |
4 |
|
5 |
use POSIX ":sys_wait_h"; |
6 |
use Socket; |
7 |
-require 'flush.pl'; |
8 |
+use IO::Handle; |
9 |
|
10 |
$::IOSIZE=1024; |
11 |
|
12 |
@@ -232,7 +232,7 @@ while (defined ($_=<STDIN>)) |
13 |
{ |
14 |
if (defined $::LogFile) |
15 |
{ print LOGFILE $_; |
16 |
- flush(LOGFILE); |
17 |
+ LOGFILE->flush(); |
18 |
} |
19 |
chomp; |
20 |
|
21 |
@@ -259,7 +259,7 @@ while (defined ($_=<STDIN>)) |
22 |
} |
23 |
} |
24 |
|
25 |
- flush(STDOUT); |
26 |
+ STDOUT->flush(); |
27 |
} |
28 |
|
29 |
exit 0; |
30 |
@@ -789,14 +788,16 @@ sub proxy_forkchild($$$) |
31 |
} |
32 |
|
33 |
# dispatch request and headers |
34 |
- printflush(GCHILD_WRITE,"$method $uri $v1 $v2\n") |
35 |
+ print GCHILD_WRITE "$method $uri $v1 $v2\n" |
36 |
|| die "tell grandchild the request: $!"; |
37 |
+ GCHILD_WRITE->flush(); |
38 |
|
39 |
print PROXY "$method $uri HTTP/$v1.$v2\r\n"; |
40 |
for my $H (@hdrs) |
41 |
{ print PROXY $H->[0], ":", $H->[1], "\r\n"; |
42 |
} |
43 |
- printflush(PROXY,"\r\n"); |
44 |
+ print PROXY "\r\n"; |
45 |
+ PROXY->flush(); |
46 |
##warn "[$$]: sent rq to proxy\n"; |
47 |
|
48 |
proxy_copybody(CONN,PROXY,$method,$persist,\@hdrs) |
49 |
@@ -965,8 +966,9 @@ sub proxy_grandchild($) |
50 |
} |
51 |
|
52 |
warn "[$child:$$]: pass response to parent\n"; |
53 |
- printflush(TOCHILD,($persist ? PERSIST : CLOSE)." $code $info") |
54 |
+ print TOCHILD ($persist ? PERSIST : CLOSE)." $code $info" |
55 |
|| die "[$child:$$]: print(TOCHILD) fails: $!"; |
56 |
+ TOCHILD->flush(); |
57 |
warn "[$child:$$]: told parent, passing response to client\n"; |
58 |
|
59 |
# copy to child |
60 |
@@ -974,7 +976,8 @@ sub proxy_grandchild($) |
61 |
for my $H (@hdrs) |
62 |
{ print CONN $H->[0], ":", $H->[1], "\r\n"; |
63 |
} |
64 |
- printflush(CONN,"\r\n"); |
65 |
+ print CONN "\r\n"; |
66 |
+ CONN->flush(); |
67 |
|
68 |
# see RFC2616 section 10 |
69 |
if ( |
70 |
@@ -1050,11 +1053,13 @@ sub proxy_copycl($$$) |
71 |
) |
72 |
{ |
73 |
##warn "[$$]: read ".length($_)." bytes of request body\n"; |
74 |
- if (! printflush($to,$_)) |
75 |
- { warn "$::cmd: [$$]: printflush($to,..): $!"; |
76 |
+ $to->autoflush(1); |
77 |
+ if (! print $to $_) |
78 |
+ { warn "$::cmd: [$$]: print $to ..): $!"; |
79 |
$ok=0; |
80 |
last COPY; |
81 |
} |
82 |
+ $to->autoflush(0); |
83 |
$cl-=length if defined $cl; |
84 |
} |
85 |
warn "[$$]: finished unchunked body, ok=$ok"; |
86 |
@@ -1083,10 +1088,10 @@ sub proxy_copychunked($$) |
87 |
{ print $to $_; |
88 |
$chunksize-=length; |
89 |
} |
90 |
- flush($to); |
91 |
+ $to->flush(); |
92 |
} |
93 |
|
94 |
- flush($to); |
95 |
+ $to->flush(); |
96 |
|
97 |
# pass trailer headers |
98 |
while (defined($_=<$from>) && !/^\r?\n/) |
99 |
@@ -1096,7 +1101,7 @@ sub proxy_copychunked($$) |
100 |
{ ##warn "[$$]: final trailer: $_"; |
101 |
print $to $_; |
102 |
} |
103 |
- flush($to); |
104 |
+ $to->flush(); |
105 |
|
106 |
return (1,""); |
107 |
} |