Changeset 227

Show
Ignore:
Timestamp:
03/19/07 15:22:07 (2 years ago)
Author:
matt
Message:

Fixes for reading all of POST data when it comes in

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/AxKit2/Client.pm

    r219 r227  
    223223sub hook_body_data_end { 
    224224    my ($self, $ret) = @_; 
    225     if ($ret == DECLINED || $ret == DONE) { 
     225    print "body_data_end got: ", AxKit2::Constants::return_code($ret), "\n"; 
     226    if ($ret == DONE) { 
    226227        return $self->process_request(); 
     228    } 
     229    elsif ($ret == DECLINED) { 
     230        if ($self->done_body) { 
     231            return $self->process_request(); 
     232        } 
     233        return 1; 
    227234    } 
    228235    elsif ($ret == OK) { 
  • trunk/lib/AxKit2/Connection.pm

    r210 r227  
    5757    continuation 
    5858    keep_alive_count 
     59    to_read 
    5960    ); 
    6061 
     
    9899     
    99100    $self->{headers_string} = ''; 
     101    $self->{to_read} = 0; 
    100102    $self->{closed} = 0; 
    101103    $self->{ditch_leading_rn} = 0; # TODO - work out how to set that... 
     
    220222sub close     { my AxKit2::Connection $self = shift; $self->{sock_closed}++; $self->{notes} = undef; $self->SUPER::close(@_) } 
    221223 
     224sub done_body { 
     225    my AxKit2::Connection $self = shift; 
     226    return $self->{to_read} == 0; 
     227} 
     228 
    222229sub event_read { 
    223230    my AxKit2::Connection $self = shift; 
     
    226233    if ($self->{headers_in}) { 
    227234        # already got the headers... do we get a body too? 
    228         my $bref = $self->read(8192); 
     235        my $bref = $self->read($self->{to_read}); 
    229236        return $self->close($!) unless defined $bref; 
     237        my $read_len = length($$bref); 
     238        $self->{to_read} -= $read_len; 
    230239        return $self->hook_body_data($bref); 
    231240    } 
     
    281290        $self->{headers_in} = AxKit2::HTTPHeaders->new(\("GET / HTTP/1.0\r\n\r\n")); 
    282291        $self->default_error_out(BAD_REQUEST); 
     292    } 
     293 
     294    if (my $len = $self->{headers_in}->header('Content-Length')) { 
     295        $self->{to_read} = $len; 
    283296    } 
    284297     
     
    434447    $self->{notes}                 = {}; 
    435448    $self->{path_config}           = undef; 
     449    $self->{to_read}               = 0; 
    436450     
    437451    # NOTE: because we only speak 1.0 to clients they can't have 
  • trunk/plugins/parse_post_data

    r223 r227  
    5757    if (length($data) > $remaining) { 
    5858        # IE sends extra \r\n after POST data 
     59        $client->push_back_read(substr($data, $remaining)); 
    5960        $data =~ s/\r\n\z//; 
    6061    } 
  • trunk/plugins/serve_cgi

    r205 r227  
    7878    my ($self, $bdata) = @_; 
    7979    # TODO: Save to a temp fh. Re-open STDIN on that FH when we exec the cgi 
    80     return DONE
     80    return DECLINED
    8181} 
    8282 
  • trunk/plugins/uri_to_file

    r219 r227  
    6666    my $root = $self->config->path; 
    6767     
     68    print "Root: $root\n"; 
     69     
    6870    $uri =~ s/^\Q$root// || die "$uri did not match config path $root"; 
    6971