Mercurial > hg > nginx-tests
comparison http_keepalive.t @ 1508:1a409a166420
Tests: fixed http_keepalive.t with short reads and double logging.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 16 Sep 2019 19:00:29 +0300 |
parents | 6c4f9941ae9f |
children | 1603f2bad385 |
comparison
equal
deleted
inserted
replaced
1507:8958b5b53c25 | 1508:1a409a166420 |
---|---|
106 | 106 |
107 ############################################################################### | 107 ############################################################################### |
108 | 108 |
109 sub http_keepalive { | 109 sub http_keepalive { |
110 my ($url, %opts) = @_; | 110 my ($url, %opts) = @_; |
111 my $data = ''; | 111 my $total = ''; |
112 | 112 |
113 $opts{ua} = $opts{ua} || ''; | 113 $opts{ua} = $opts{ua} || ''; |
114 $opts{req} = $opts{req} || 1; | 114 $opts{req} = $opts{req} || 1; |
115 $opts{sleep} = $opts{sleep} || 0; | 115 $opts{sleep} = $opts{sleep} || 0; |
116 $opts{method} = $opts{method} || 'GET'; | 116 $opts{method} = $opts{method} || 'GET'; |
128 Host: localhost | 128 Host: localhost |
129 User-Agent: $opts{ua} | 129 User-Agent: $opts{ua} |
130 | 130 |
131 EOF | 131 EOF |
132 | 132 |
133 my $data = ''; | |
134 | |
133 while (IO::Select->new($s)->can_read(3)) { | 135 while (IO::Select->new($s)->can_read(3)) { |
134 sysread($s, my $buffer, 4096) or last; | 136 sysread($s, my $buffer, 4096) or last; |
135 $data .= $buffer; | 137 $data .= $buffer; |
136 last if $data =~ /^\x0d\x0a/ms; | 138 last if $data =~ /^\x0d\x0a/ms; |
137 } | 139 } |
138 | 140 |
139 log_in($data); | 141 log_in($data); |
142 | |
143 $total .= $data; | |
140 } | 144 } |
141 | 145 |
142 return $data; | 146 return $total; |
143 } | 147 } |
144 | 148 |
145 sub count_keepalive { | 149 sub count_keepalive { |
146 my ($str) = @_; | 150 my ($str) = @_; |
147 return $str =~ s/Connection: keep-alive//g; | 151 return $str =~ s/Connection: keep-alive//g; |