Show
Ignore:
Timestamp:
08/17/08 12:25:01 (5 years ago)
Author:
tokuhirom
Message:

refactoring

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/HTTP-Engine/trunk/lib/HTTP/Engine/Interface/Standalone.pm

    r17742 r17753  
    139139    while (1) { 
    140140        # FIXME refactor an HTTP push parser 
    141         my($path, $query_string) = split /\?/, $uri, 2; 
    142  
    143         my $headers; 
    144141 
    145142        # Parse headers 
    146143        # taken from HTTP::Message, which is unfortunately not really reusable 
    147         if ($protocol >= 1) { 
    148             my @hdr; 
    149             while ( length(my $line = $self->_get_line($remote)) ) { 
    150                 if ($line =~ s/^([^\s:]+)[ \t]*: ?(.*)//) { 
    151                     push(@hdr, $1, $2); 
     144        my $headers = do { 
     145            if ($protocol >= 1) { 
     146                my @hdr; 
     147                while ( length(my $line = $self->_get_line($remote)) ) { 
     148                    if ($line =~ s/^([^\s:]+)[ \t]*: ?(.*)//) { 
     149                        push(@hdr, $1, $2); 
     150                    } 
     151                    elsif (@hdr && $line =~ s/^([ \t].*)//) { 
     152                        $hdr[-1] .= "\n$1"; 
     153                    } else { 
     154                        last; 
     155                    } 
    152156                } 
    153                 elsif (@hdr && $line =~ s/^([ \t].*)//) { 
    154                     $hdr[-1] .= "\n$1"; 
    155                 } else { 
    156                     last; 
    157                 } 
     157                HTTP::Headers->new(@hdr); 
     158            } else { 
     159                HTTP::Headers->new; 
    158160            } 
    159             $headers = HTTP::Headers->new(@hdr); 
    160         } else { 
    161             $headers = HTTP::Headers->new; 
    162         } 
     161        }; 
    163162 
    164163        # Pass flow control to HTTP::Engine 
     
    204203    } 
    205204 
    206     $self->request_builder->_io_read($remote, my $buf, 4096) if $sel->can_read(0); # IE bk 
     205    $self->request_builder->_io_read($remote, my $buf, 4096) if $sel->can_read(0); # IE hack 
    207206    close $remote; 
    208207}