<div dir="ltr"><div><div><div><div>HI All,<br><br></div>So I've solved the issue with sessions and it appears as though it is mucking up the delayed subroutine and I've written a test case based on the example in the docs and I'm surely missing something as it doesn't work properly, since it blocks.<br><br></div>Here is a simple case of delayed blocking, I've moved the session code outside the subroutine which now does return.<br><br>get '/Load/:ID' => sub {<br> my $ID = params->{'ID'};<br> my $Username = "Test";<br> session 'Username' => $Username;<br> delayed {<br> my $TextToWrite = ReturnText();<br> sleep(10); # Do something that takes a few seconds<br> content "$TextToWrite";<br> done;<br> };<br>};<br><br></div>at the "sleep" function, the application basically stops, waiting for sleep to complete. <br><br></div>The docs confused me as well, it says:<br><br><pre><div class=""><code class=""> </code><code class="">content </code><code class="">'Hello, again!'</code><code class="">;</code></div><div class=""> </div><div class=""><code class=""> </code><code class=""># when done, close the connection</code></div><div class=""><code class=""> </code><code class="">done;</code></div><div class=""> </div><div class=""><code class=""> </code><code class=""># do whatever you want else, asynchronously</code></div><div class=""><code class=""> </code><code class=""># the user socket closed by now</code></div><div class=""><code class=""> </code><code class="">...</code></div><div class=""><code class=""> </code><code class="">};</code></div><div class=""><code class="">};<br><br></code></div><div class=""><code class="">At the end it talks about doing stuff asynchronously, implying that <br>whatever was done previously was not asynchronous?<br><br></code></div><div class=""><code class="">So yeah, some clarification would be awesome, or just someone with an example which works.<br><br><br></code></div><div class=""><code class="">David<br></code></div><div class=""><code class=""><br><br></code></div></pre><br><div><br><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 17, 2015 at 1:56 PM, David H <span dir="ltr"><<a href="mailto:untg99@gmail.com" target="_blank">untg99@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Thanks,<br></div>I've changed the custom headers.<br></div>There is something which is causing a "400 Bad Response".<br><br></div>I've narrowed it down to this simple use case:<br>get '/Load/:ID' => sub {<br> my $ID = params->{'ID'};<br> delayed {<br> my $TextToWrite = ReturnText(); # Just returns "hi", works fine.<br> my $Username = "Test";<br> session 'Username' => $Username; # Causes the whole thing to to return "400 Bad Response" and not work at all.<br> header 'Content-Type' => "text/html; charset=UTF-8";<br> flush;<br> content "$TextToWrite";<br> done;<br><br><br> };<br>};<br><br></div><div>Notice the "session 'Username' => $Username."<br><br></div><div>That causes a "400 Bad Response" error. I'm guessing something to do with the session being set and returning before other stuff has happened??<br><br></div><div>Thanks,<br><br></div><div>David<br></div><div><br></div></div><div><div><br></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 17, 2015 at 11:43 AM, Warren Young <span dir="ltr"><<a href="mailto:wyml@etr-usa.com" target="_blank">wyml@etr-usa.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Nov 16, 2015, at 6:09 PM, David H <<a href="mailto:untg99@gmail.com" target="_blank">untg99@gmail.com</a>> wrote:<br>
><br>
> add_header 'X-Foo' => 'Bar’;<br>
<br>
That’s probably an old DSL keyword. It looks like it was replaced with ‘header’:<br>
<br>
<a href="https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Manual.pod#header" rel="noreferrer" target="_blank">https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Manual.pod#header</a><br>
<br>
Anyway, do you really need to set custom HTTP headers here? It’s just an example. If your app doesn’t need that, remove the line entirely.<br>
<div><div>_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" rel="noreferrer" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>