Update: If you submit your POST request to Dancer using Angular's $resource controller, and you try to return either a redirect() or a send_file() response, Angular will hijack it and it will never be returned to the client. Nothing at all is returned to the browser, and nothing is printed to the log, because Dancer thinks the response was sent out, and even the browser sees a 200 HTTP response code. But somehow Angular holds on to the response and doesn't display it.

I solved the issue in my case by creating a standard HTTP POST form.

Update: I titled my post wrongly, changed to reflect that the issue is with POST requests. Sorry for the confusion.

Hi all,

Is there a restriction in the use of Dancer's send_file() with in-memory filehandles that limits its use to GET requests? My experimentation indicates so, but the docs don't mention it.

Update: Here is a short example:

This code results in the browser downloading a CSV file:

get '/test/csv' => sub { my $csv = "foo, bar, baz"; send_file( \$csv, content_type => 'text/csv', filename => 'qux.csv +' ); };
While this produces nothing returned to the browser and nothing in the error log:
post '/test/csv' => sub { my $csv = "foo, bar, baz"; send_file( \$csv, content_type => 'text/csv', filename => 'qux.csv +' ); };

Update: Tried using return redirect '/get_resource'; in the POST handler but even so there is nothing output to the log or the browser.

Thanks!

The way forward always starts with a minimal test.

In reply to Solved: Dancer::send_file doesn't work with POST? ( Angular JS hijacks the response) by 1nickt

Title:
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, details, 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, summary, 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.