Replies: 4 comments 13 replies
-
Which part of the documentation are you referring to? |
Beta Was this translation helpful? Give feedback.
-
I'm referring to that bit in Mojo::UserAgent:
So how does one prevent the code from continuing until the promise is either satisfied or in error? With Hence, how can I make the code work properly if |
Beta Was this translation helpful? Give feedback.
-
I found out how to fix the promise code I wrote above. Instead of wrongly saying:
I need to write:
to make sure the flow does not go past |
Beta Was this translation helpful? Give feedback.
-
Got it, thanks. |
Beta Was this translation helpful? Give feedback.
-
I wanted to try the low-level promises, but apparently they do not work as expected (as is documented, that is), whereas
async
/await
do.Here is a sample script that does NOT work as expected, call it
bug-promise.pl
:Running it with
./bug-promise.pl daemon -l http://localhost:12080
,From another terminal, running
curl -D - http://localhost:12080/wrap
yields the unexpected 503 error.The debugging output is:
Rewriting using
async
/await
yields the followingbug.pl
script (which is working):Running it with
./bug.pl daemon -l http://localhost:12080
,From another terminal, running
curl -D - http://localhost:12080/wrap
yields the expected output:And the debugging logs are:
Why is the promise code not working? Obviously, I'm totally new to Mojolicious and following the documentation blindly, so I must have been missing something, or there is a documentation bug, or there is a code bug.
BTW: there is a problem with the
$req>body()
routine which returns an empty string despite$req->body_size
being non-zero. Looking at the code, I figured I would have to use$req->build_body()
to pass in the original body (when testing the above example with a POST and a few "form" parameters, as incurl -X POST -F foo=bar ...
) because the body content was obviously multipart. But not having:surprised me a lot.
Beta Was this translation helpful? Give feedback.
All reactions