Changeset 734
- Timestamp:
- 05/13/06 08:16:07
- Files:
-
- branches/feature-server/plagger/lib/Plagger/Plugin/Server/Engine/PreFork.pm (modified) (2 diffs)
- branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol.pm (modified) (1 diff)
- branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol/HTTP.pm (modified) (5 diffs)
- branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol/PLAGGER.pm (added)
- branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol/POP3.pm (modified) (1 diff)
- branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol/SMTP.pm (modified) (1 diff)
- branches/feature-server/plagger/lib/Plagger/Plugin/Server/Push (added)
- branches/feature-server/plagger/lib/Plagger/Plugin/Server/Push.pm (added)
- branches/feature-server/plagger/lib/Plagger/Plugin/Server/Push/Cron.pm (added)
- branches/feature-server/plagger/lib/Plagger/Plugin/Server/Push/IRC.pm (added)
- branches/feature-server/plagger/lib/Plagger/Server.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/feature-server/plagger/lib/Plagger/Plugin/Server/Engine/PreFork.pm
r709 r734 55 55 56 56 $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 57 64 $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)); 60 66 $self->context->engine_run($req); 61 67 last; … … 66 72 } 67 73 74 #shutdown 75 sub pre_server_close_hook { 76 my $self = shift; 77 $self->log(debug => "pre_server_close_hook."); 78 $self->context->run_hook('push.stop'); 79 } 68 80 1; branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol.pm
r702 r734 9 9 } 10 10 11 11 12 sub proto { 'tcp' } 12 sub service {} 13 sub service { 14 my($self, $service) = @_; 15 $self->{service} || $service; 16 } 13 17 14 sub session_init {} 18 sub session_init { 19 my $self = shift; 20 $self->status(0); 21 $self->body(''); 22 } 23 24 sub pre_input { shift } 15 25 sub input {} 16 26 sub output {} branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol/HTTP.pm
r723 r734 10 10 11 11 sub proto { 'tcp' } 12 sub service { 'http' } 12 sub service { 13 my $self = shift; 14 $self->SUPER::service('http'); 15 } 13 16 14 17 sub session_init { … … 28 31 29 32 while (my($name, $value) = splice @header, 0, 2) { 30 $self->{headers_out}->{$name} = $value;33 $self->{headers_out}->{$name} = $value; 31 34 } 32 35 } … … 39 42 $line = <STDIN>; 40 43 unless ($line =~ m!^(GET|POST) ([^ ]+) HTTP/\d\.\d\r\n!) { 41 $self->status(400);42 return 0;44 $self->status(400); 45 return 0; 43 46 }; 44 47 my $method = $1; … … 46 49 47 50 while (<STDIN> =~ /^([^:]+): (.+)\r\n/) { 48 $self->{headers_in}->{$1} = $2;51 $self->{headers_in}->{$1} = $2; 49 52 } 50 53 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"; 53 56 } 54 57 … … 66 69 my $other_headers; 67 70 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'; 70 73 } 71 74 72 75 my $body; 73 76 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; 76 79 } 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; 79 82 } 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; 82 85 } 83 86 utf8::encode($body) if utf8::is_utf8($body); branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol/POP3.pm
r709 r734 17 17 18 18 sub proto { 'tcp' } 19 sub service { 'pop3' } 19 sub service { 20 my $self = shift; 21 $self->SUPER::service('pop3'); 22 } 20 23 21 24 sub session_init { branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol/SMTP.pm
r709 r734 8 8 9 9 sub proto { 'tcp' } 10 sub service { 'smtp' } 10 sub service { 11 my $self = shift; 12 $self->SUPER::service('smtp'); 13 } 11 14 12 15 sub session_init { branches/feature-server/plagger/lib/Plagger/Server.pm
r702 r734 58 58 59 59 $self->run_hook('pull.init'); 60 $self->run_hook('push.init'); 61 62 $self->run_hook('push.start'); 60 63 61 64 $self->run_hook('engine.run');
