[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-modperl-cvs
Subject: cvs commit: modperl-2.0/t/response/TestApache read.pm
From: stas () apache ! org
Date: 2002-12-17 7:15:46
[Download RAW message or body]
stas 2002/12/16 23:15:46
Modified: xs/Apache/RequestIO Apache__RequestIO.h
. Changes
t/response/TestApache read.pm
Log:
fix $r->read to read all the requested amount of data if possible,
adjust the test TestApache::read to verify that
Revision Changes Path
1.29 +24 -5 modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h
Index: Apache__RequestIO.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Apache__RequestIO.h 14 Aug 2002 14:54:47 -0000 1.28
+++ Apache__RequestIO.h 17 Dec 2002 07:15:46 -0000 1.29
@@ -177,7 +177,7 @@
SV *buffer, int bufsiz,
int offset)
{
- long nrd = 0;
+ long total = 0;
int rc;
if ((rc = mpxs_setup_client_block(r)) != APR_SUCCESS) {
@@ -185,20 +185,39 @@
}
if (mpxs_should_client_block(r)) {
+ long nrd;
/* ap_should_client_block() will return 0 if r->read_length */
mpxs_sv_grow(buffer, bufsiz+offset);
- nrd = ap_get_client_block(r, SvPVX(buffer)+offset, bufsiz);
+ while (bufsiz) {
+ nrd = ap_get_client_block(r, SvPVX(buffer)+offset+total, bufsiz);
+ if (nrd > 0) {
+ total += nrd;
+ bufsiz -= nrd;
+ }
+ else if (nrd == 0) {
+ break;
+ }
+ else {
+ /*
+ * XXX: as stated in ap_get_client_block, the real
+ * error gets lots, so we only know that there was one
+ */
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+ "mod_perl: $r->read failed to read");
+ break;
+ }
+ }
}
- if (nrd > 0) {
- mpxs_sv_cur_set(buffer, nrd+offset);
+ if (total > 0) {
+ mpxs_sv_cur_set(buffer, offset+total);
SvTAINTED_on(buffer);
}
else {
sv_setpvn(buffer, "", 0);
}
- return nrd;
+ return total;
}
static MP_INLINE
1.85 +3 -0 modperl-2.0/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- Changes 15 Dec 2002 08:30:39 -0000 1.84
+++ Changes 17 Dec 2002 07:15:46 -0000 1.85
@@ -10,6 +10,9 @@
=item 1.99_08-dev
+fix $r->read to read all the requested amount of data if possible,
+adjust the test TestApache::read to verify that [Stas]
+
fix the method content() in Apache::compat to read a whole request
body. same for ModPerl::Test::read_post. add tests. [Stas]
1.3 +8 -4 modperl-2.0/t/response/TestApache/read.pm
Index: read.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestApache/read.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- read.pm 11 Apr 2002 11:08:44 -0000 1.2
+++ read.pm 17 Dec 2002 07:15:46 -0000 1.3
@@ -18,11 +18,15 @@
my $buffer = "";
my $bufsiz = $r->args || BUFSIZ;
- while ((my($offset) = length($buffer)) < $ct) {
- my $remain = $ct - $offset;
+ my $offset = 0;
+ while (my $remain = $ct - $offset) {
my $len = $remain >= $bufsiz ? $bufsiz : $remain;
- last unless $len > 0;
- $r->read($buffer, $len, $offset);
+ my $read = $r->read($buffer, $len, $offset);
+ if ($read != $len) {
+ die "read only ${read}b, while ${len}b were requested\n";
+ }
+ last unless $read > 0;
+ $offset += $read;
}
#make sure we dont block after all data is read
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic