Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Scratching my head on this one. My app works fine, except it sends a 500 Internal Server Error status rather than 200 OK.

Content displays fine in the browser. I only noticed it when adding error checking to the client app.

I've stripped it down to a minimal case:

package Test; use strict; use warnings; use base qw(CGI::Application); sub setup { my $self = shift; # default runmodes $self->start_mode('do_main'); $self->mode_param('m'); $self->run_modes([qw/ do_main testtt /]); } sub cgiapp_prerun { my $self = shift; $self->header_add( 'Content-type' => 'text/plain' ); } sub testtt { my $self = shift; return "test - OK to here"; } sub do_main { my $self = shift; return "main - OK to here"; } 1;

and call the url with query string:


I get a screwed up content-type header back:

Content-Type: content-type

If I comment out the header line, the page serves correctly with the text/html content type (but I need text/plain!).

Changing the capitalization of the header name appears to make no difference.

Weird thing is that I have another app on the same server that works correctly, but I can't see what's any different in it.

Any ideas? AM I missing something extremely simple here?

EDIT: as always, writing out this question prods me to find the solution by myself.

I should have used:

$self->header_add( '-type' => 'text/plain' );

The other app wasn't looking at the status header, but had the same issue (now I check).

OK, that's enough for me for today :)

In reply to CGI::Application header (typo, heh) by cLive ;-)

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [Discipulus]: my son was used to say being left-handed on both hands..
    [erix]: ambysinistral ;)
    [Discipulus]: the fun is the mother used to say ' two left hand' to describe people unabel to manual work..

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (5)
    As of 2018-02-19 12:19 GMT
    Find Nodes?
      Voting Booth?
      When it is dark outside I am happiest to see ...

      Results (264 votes). Check out past polls.