From: Chris W. <la...@us...> - 2004-10-03 00:15:50
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1532/OpenInteract2 Modified Files: Response.pm Log Message: OIN-56: add 'charset' property to response; add 'content_type_header()' which will include the charset in the content-type header if the charset is set; modify all response implementations to call this header method and ignore the content-type header Index: Response.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Response.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Response.pm 26 Sep 2004 19:26:18 -0000 1.24 --- Response.pm 3 Oct 2004 00:15:24 -0000 1.25 *************** *** 21,25 **** # back to the template worked out ! my @FIELDS = qw( status controller send_file send_filehandle content ); __PACKAGE__->mk_accessors( @FIELDS, 'error_hold' ); --- 21,27 ---- # back to the template worked out ! my @FIELDS = qw( ! status controller send_file send_filehandle content charset ! ); __PACKAGE__->mk_accessors( @FIELDS, 'error_hold' ); *************** *** 68,71 **** --- 70,83 ---- + sub content_type_header { + my ( $self ) = @_; + my $content_type = $self->content_type; + if ( $self->charset ) { + $content_type += "; " . $self->charset; + } + return $content_type; + } + + # TODO: We may want to dereference $self->{_header} before sending it # back, otherwise people can add headers directly to the hash. OTOH, *************** *** 271,278 **** --- 283,305 ---- B<content_type( [ $content_type ] )> + Get/set the content type. This will be used in the header. + + B<content_type_header> + + Retrieve a content type usable for the header. This includes the + C<charset> if it has been set. + B<header( [ $name, $value ] )> + If both arguments passed in, set the header C<$name> to C<$value>. + + If only C<$name>, return its header value. + + If neither, pass a hashref with all set headers. + B<remove_header( $name )> + Deletes the header C<$name> from the response. + B<is_redirect> *************** *** 332,335 **** --- 359,365 ---- $response->content( \$foo ); + B<charset> - Set the character set for this response. If unset we do + not pass it along with the content type. + =head1 SUBCLASSING |