Changeset 734

Show
Ignore:
Timestamp:
05/13/06 08:16:07
Author:
ko
Message:

Added to Server Push Type

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/feature-server/plagger/lib/Plagger/Plugin/Server/Engine/PreFork.pm

    r709 r734  
    5555 
    5656            $protocol->session_init; 
     57            my $req = Plagger::Server::Request->new(protocol => $protocol, server => $server); 
     58            $protocol = $protocol->pre_input($req); 
     59            $req->protocol($protocol); 
     60            $self->log(debug => "protocol is a:" . ref($protocol)); 
     61            next unless ref($protocol) && $protocol->input($req); 
     62            $self->log(debug => "protocol is b:" . ref($protocol)); 
     63 
    5764            $use_protocol = $protocol; 
    58             my $req = Plagger::Server::Request->new(protocol => $protocol, server => $server); 
    59             next unless $protocol->input($req); 
     65            $self->log(debug => "protocol is " . ref($use_protocol)); 
    6066            $self->context->engine_run($req); 
    6167            last; 
     
    6672} 
    6773 
     74#shutdown 
     75sub pre_server_close_hook { 
     76    my $self = shift; 
     77    $self->log(debug => "pre_server_close_hook."); 
     78    $self->context->run_hook('push.stop'); 
     79} 
    68801; 
  • branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol.pm

    r702 r734  
    99} 
    1010 
     11 
    1112sub proto { 'tcp' } 
    12 sub service {} 
     13sub service {  
     14    my($self, $service) = @_; 
     15    $self->{service} || $service; 
     16
    1317 
    14 sub session_init {} 
     18sub session_init { 
     19    my $self = shift; 
     20    $self->status(0); 
     21    $self->body(''); 
     22
     23 
     24sub pre_input { shift } 
    1525sub input {} 
    1626sub output {} 
  • branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol/HTTP.pm

    r723 r734  
    1010 
    1111sub proto { 'tcp' } 
    12 sub service { 'http' } 
     12sub service { 
     13    my $self = shift; 
     14    $self->SUPER::service('http'); 
     15
    1316 
    1417sub session_init { 
     
    2831 
    2932    while (my($name, $value) = splice @header, 0, 2) { 
    30        $self->{headers_out}->{$name} = $value; 
     33        $self->{headers_out}->{$name} = $value; 
    3134    } 
    3235} 
     
    3942    $line = <STDIN>; 
    4043    unless ($line =~ m!^(GET|POST) ([^ ]+) HTTP/\d\.\d\r\n!) { 
    41        $self->status(400); 
    42        return 0; 
     44        $self->status(400); 
     45        return 0; 
    4346    }; 
    4447    my $method = $1; 
     
    4649 
    4750    while (<STDIN> =~ /^([^:]+): (.+)\r\n/) { 
    48        $self->{headers_in}->{$1} = $2; 
     51        $self->{headers_in}->{$1} = $2; 
    4952    } 
    5053    if ($method eq 'POST') { 
    51        read(STDIN, my $data, $self->headers_in->{'Content-Length'} || 0); 
    52        $query .= "?$data"; 
     54        read(STDIN, my $data, $self->headers_in->{'Content-Length'} || 0); 
     55        $query .= "?$data"; 
    5356    } 
    5457 
     
    6669    my $other_headers; 
    6770    foreach my $name (%{ $self->headers_out }) { 
    68        $other_headers .= sprintf("%s: %s\r\n", $name, $self->headers_out->{$name}); 
    69        $self->status(302) if $name eq 'Location'; 
     71        $other_headers .= sprintf("%s: %s\r\n", $name, $self->headers_out->{$name}); 
     72        $self->status(302) if $name eq 'Location'; 
    7073    } 
    7174 
    7275    my $body; 
    7376    if ($self->status eq 302) { 
    74        $body = "HTTP/1.0 302 Plagger Redirect\r\n"; 
    75        print $body; 
     77        $body = "HTTP/1.0 302 Plagger Redirect\r\n"; 
     78        print $body; 
    7679    } elsif ($self->status) { 
    77        $body = "HTTP/1.0 500 Plagger Error\r\n"; 
    78        print $body; 
     80        $body = "HTTP/1.0 500 Plagger Error\r\n"; 
     81        print $body; 
    7982    } else { 
    80        print "HTTP/1.0 200 OK\r\n"; 
    81        $body = $self->body; 
     83        print "HTTP/1.0 200 OK\r\n"; 
     84        $body = $self->body; 
    8285   } 
    8386    utf8::encode($body) if utf8::is_utf8($body); 
  • branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol/POP3.pm

    r709 r734  
    1717 
    1818sub proto { 'tcp' } 
    19 sub service { 'pop3' } 
     19sub service { 
     20    my $self = shift; 
     21    $self->SUPER::service('pop3'); 
     22
    2023 
    2124sub session_init { 
  • branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol/SMTP.pm

    r709 r734  
    88 
    99sub proto { 'tcp' } 
    10 sub service { 'smtp' } 
     10sub service { 
     11    my $self = shift; 
     12    $self->SUPER::service('smtp'); 
     13
    1114 
    1215sub session_init { 
  • branches/feature-server/plagger/lib/Plagger/Server.pm

    r702 r734  
    5858 
    5959    $self->run_hook('pull.init'); 
     60    $self->run_hook('push.init'); 
     61 
     62    $self->run_hook('push.start'); 
    6063 
    6164    $self->run_hook('engine.run');