Changeset 810
- Timestamp:
- 12/11/08 23:43:05 (12 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
CHANGES (modified) (1 diff)
-
lib/Perlbal/ClientHTTP.pm (modified) (4 diffs)
-
t/20-put.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CHANGES
r809 r810 1 -- Allow zero byte PUT requests (in normal PUT situations) 1 2 2 3 -- Fix for serving files from the filesystem over SSL (Greg Denton) -
trunk/lib/Perlbal/ClientHTTP.pm
r763 r810 146 146 # bigger than any specified max put size 147 147 return $self->send_response(400, "Content-length of $clen is invalid.") 148 if !$clen || 148 if ! defined($clen) || 149 $clen < 0 || 149 150 ($self->{service}->{max_put_size} && 150 151 $clen > $self->{service}->{max_put_size}); 151 152 152 # if we have some data already from a header over-read, note it153 if ( defined $self->{read_ahead} && $self->{read_ahead} > 0) {153 # if we are supposed to read data and have some data already from a header over-read, note it 154 if ($clen && defined $self->{read_ahead} && $self->{read_ahead} > 0) { 154 155 $self->{content_length_remain} -= $self->{read_ahead}; 155 156 } … … 228 229 229 230 my $disk_path = $self->{service}->{docroot} . '/' . $path; 230 $self->start_put_open($disk_path, $filename);231 231 232 232 $self->{chunked_upload_state} = Perlbal::ChunkedUploadState->new(%{{ … … 268 268 }, 269 269 }}); 270 271 $self->start_put_open($disk_path, $filename); 270 272 271 273 return 1; … … 396 398 $self->{put_fh_filename} = "$path/$file"; 397 399 400 # We just opened the file, haven't read_ahead any bytes, are expecting 0 bytes for read and we're 401 # not in chunked mode, so close the file immediately, we're done. 402 unless ($self->{read_ahead} || $self->{content_length_remain} || $self->{chunked_upload_state}) { 403 # FIXME this should be done through AIO 404 $self->put_close; 405 return; 406 } 407 398 408 $self->put_writeout; 399 409 }); -
trunk/t/20-put.t
r358 r810 2 2 3 3 use strict; 4 use warnings; 5 4 6 use Perlbal::Test; 5 7 … … 36 38 37 39 sub put_file { 40 my %opts = @_; 38 41 my $req = HTTP::Request->new(PUT => $url); 39 42 $content = "foo bar baz\n" x 1000; 43 44 if (exists $opts{content}) { 45 $content = $opts{content} 46 } 47 40 48 $req->content($content); 49 50 if (my $headers = $opts{headers}) { 51 $req->header(@$headers); 52 } 53 41 54 my $res = $ua->request($req); 42 55 return $res->is_success; … … 83 96 ok(put_file(), "aio $mode: good put at dir1/dir2/foo.txt"); 84 97 verify_put(); 98 ok(put_file(content => "", headers => [ "Content-Length" => 0 ]), "aio $mode: zero byte file put"); 99 verify_put(); 85 100 ok(unlink($disk_file), "rm file"); 86 101 ok(rmdir("$dir/$dir1/dir2"), "rm dir2");
