Changeset 706
- Timestamp:
- 05/11/06 15:31:47
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/feature-server/plagger/lib/Plagger/Plugin/Server/Protocol/HTTP.pm
r702 r706 7 7 8 8 use base qw( Plagger::Plugin::Server::Protocol ); 9 __PACKAGE__->mk_accessors( qw(uri cgi head ders_in headders_out content_type) );9 __PACKAGE__->mk_accessors( qw(uri cgi headers_in headers_out content_type) ); 10 10 11 11 sub proto { 'tcp' } … … 19 19 $self->uri(''); 20 20 $self->cgi(''); 21 $self->head ders_in({});22 $self->head ders_out({});21 $self->headers_in({}); 22 $self->headers_out({}); 23 23 $self->content_type(''); 24 24 } 25 25 26 sub add_head ders_out {27 my($self, @head der) = @_;26 sub add_headers_out { 27 my($self, @header) = @_; 28 28 29 while (my($name, $value) = splice @head der, 0, 2) {30 $self->{head ders_out}->{$name} = $value;29 while (my($name, $value) = splice @header, 0, 2) { 30 $self->{headers_out}->{$name} = $value; 31 31 } 32 32 } … … 46 46 47 47 while (<STDIN> =~ /^([^:]+): (.+)\r\n/) { 48 $self->{head ders_in}->{$1} = $2;48 $self->{headers_in}->{$1} = $2; 49 49 } 50 50 if ($method eq 'POST') { 51 read(STDIN, my $data, $self->head ders_in->{'Content-Length'} || 0);51 read(STDIN, my $data, $self->headers_in->{'Content-Length'} || 0); 52 52 $query .= "?$data"; 53 53 } 54 54 55 my $host = $self->head ders_in->{Host} ||= sprintf("%s:%s", $self->conf->{host}, $self->conf->{port});55 my $host = $self->headers_in->{Host} ||= sprintf("%s:%s", $self->conf->{host}, $self->conf->{port}); 56 56 $self->uri(URI->new("http://$host$query")); 57 57 $self->cgi(CGI->new($self->uri->query)); … … 64 64 my $self = shift; 65 65 66 my $other_head ders;67 foreach my $name (%{ $self->head ders_out }) {68 $other_head ders .= sprintf("%s: %s\r\n", $name, $self->headders_out->{$name});66 my $other_headers; 67 foreach my $name (%{ $self->headers_out }) { 68 $other_headers .= sprintf("%s: %s\r\n", $name, $self->headers_out->{$name}); 69 69 $self->status(302) if $name eq 'Location'; 70 70 } … … 88 88 printf("Content-Type: %s\r\n", $self->content_type || 'text/html'); 89 89 printf("Content-Length: %d\r\n", length($body)); 90 print $other_head ders;90 print $other_headers; 91 91 print "\r\n"; 92 92 print $body; branches/feature-server/plagger/lib/Plagger/Plugin/Server/Pull/SimpleBbs.pm
r702 r706 46 46 47 47 my $u = $args->{req}->protocol->uri; 48 $args->{req}->protocol->add_head ders_out(Location => sprintf("%s://%s:%s%s", $u->scheme, $u->host, $u->port, $u->path));48 $args->{req}->protocol->add_headers_out(Location => sprintf("%s://%s:%s%s", $u->scheme, $u->host, $u->port, $u->path)); 49 49 } 50 50
