1nickt has asked for the wisdom of the Perl Monks concerning the following question:
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:
While this produces nothing returned to the browser and nothing in the error log:get '/test/csv' => sub { my $csv = "foo, bar, baz"; send_file( \$csv, content_type => 'text/csv', filename => 'qux.csv +' ); };
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dancer::send_file only for POST?
by Corion (Patriarch) on Nov 11, 2015 at 13:38 UTC | |
by 1nickt (Canon) on Nov 11, 2015 at 13:44 UTC | |
by Corion (Patriarch) on Nov 11, 2015 at 14:03 UTC | |
by 1nickt (Canon) on Nov 11, 2015 at 14:24 UTC | |
by Corion (Patriarch) on Nov 11, 2015 at 14:34 UTC | |
| |
|
Re: Dancer::send_file only for GET? (and POST)
by Anonymous Monk on Nov 12, 2015 at 03:39 UTC |