Skip Menu |

This queue is for tickets about the CGI-Ajax CPAN distribution.

Report information
The Basics
Id: 18914
Status: new
Priority: 0/
Queue: CGI-Ajax

People
Owner: Nobody in particular
Requestors: andrew [...] ponly.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.31
  • 0.32
  • 0.37
  • 0.38
  • 0.43
  • 0.43a
  • 0.49
  • 0.52
  • 0.56
  • 0.58
  • 0.59
  • 0.591
  • 0.6
  • 0.64
  • 0.641
  • 0.65
  • 0.651
  • 0.652
  • 0.653
  • 0.654
  • 0.66
  • 0.662
  • 0.67
  • 0.68
  • 0.681
  • 0.682
  • 0.683
  • 0.684
  • 0.69
  • 0.691
  • 0.692
  • 0.694
Fixed in: (no value)



Subject: Script sends headers before subroutine called
Subj. This is not good, because I can't work with cookies, or send other cookies. My solution: sub handle_request { my ($self) = shift; my $result; # $result takes the output of the function, if it's an # array split on __pjx__ my @other = (); # array for catching extra parameters # we need to access "fname" in the form from the web page, so make # sure there is a CGI object defined return undef unless defined $self->cgi(); my ($rv,$header) ; # get the name of the function my $func_name = $self->cgi()->param("fname")||$self->cgi->cookie('fname'); # check if the function name was created if ( defined $self->coderef_list()->{$func_name} ) { my $code = $self->coderef_list()->{$func_name}; # eval the code from the coderef, and append the output to $rv if ( ref($code) eq "CODE" ) { eval { ($result, @other) = $code->($self,$self->cgi()->param("args") ) }; if ($@) { # see if the eval caused and error and report it # Should we be more severe and die? # die. only die return $@; } if( @other ) { $rv .= join( "__pjx__", ($result, @other) ); warn "rv = $rv\n" if ( $self->DEBUG() ); } else { if ( defined $result ) { $rv .= $result; } } } # end if ref = CODE if ( $self->cgi()->can('header') ) { $header = $self->cgi()->header( $self->cgi_header_extra() ); } else { # don't have an object with a "header()" method, so just create # a mimimal one $header = "Content-Type: text/html;"; # TODO: $header .= header $self->cgi_header_extra(); $header .= "\n\n"; } } else { # # problems with the URL, return a CGI rrror print STDERR "POSSIBLE SECURITY INCIDENT! Browser from ", $self->cgi()->remote_addr(); print STDERR "\trequested URL: ", $self->cgi()->url(); print STDERR "\tfname request: ", $self->cgi()->param('fname'); print STDERR " -- returning Bad Request status 400\n"; if ( $self->cgi()->can('header') ) { return($self->cgi()->header( -status=>'400' )); } else { # don't have an object with a "header()" method, so just create # a mimimal one with 400 error $rv = "Status: 400\nContent-Type: text/html;\n\n"; } } return "$header$rv"; }