The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2017-05-02

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:00 eday i'd like to just pass in a delay object for them all to share and avoid having to also pass in a UserAgent object if possible
00:03 cng https://metacpan.org/pod/Mojo::UserAgent#get: “Perform *blocking* GET request”
00:03 cng Try https://metacpan.org/pod/Mojo::UserAgent#start1 instead
00:03 cng “You can also append a callback to perform requests non-blocking”
00:04 cng But pls note, I’m still a novice with the Mojo async stuff; you may want to wait for some more experienced advice as well. Anyway `start` with a callback is how I solved it couple weeks back
00:08 eday i want non-blocking, which is why i'm proving the callback. I'm also using the delay object to wait until all requests complete
00:09 cng That’s fine, but the ->get request is blocking, so don’t use that.
00:09 marty joined #mojo
00:10 eday it's non-blocking if you supply a callback - see the second block of this link you shared: https://metacpan.org/pod/Mojo::UserAgent#get
00:11 eday (it looks like get/put/delete/etc are really just convenience wrappers around build_tx/start)
00:11 cng ok, then wait for the more experienced.
00:12 cng I know that I used `start` to fix the issue I was having with blocking requests
00:14 eday thanks i just tried replacing get with build_tx/start and see the same behavior
00:15 cng I’ll be watching to see what the more experienced have to say about it. “looks” like both should work.
00:16 eday cng: yeah, i was surprised using two UserAgent objects broke things
00:17 cng I don’t think that’s the issue, but really just a guess. Opportunity for learning :-D
00:19 gizmomathboy joined #mojo
00:22 eday cng: yeah, that's the hope! :)
00:46 Grinnz eday: scoping issue; the Mojo::UserAgent object goes out of scope once your get() function returns
00:46 Grinnz it needs to stay in scope until you run the event loop (in $delay->wait, in this case)
00:47 cng Damn, I should have caught that. I now recall I had *two* issues a couple weeks back, the other issue was scope!
00:48 Grinnz you can keep it in scope by naming the inner $ua something different, and adding "undef $ua" to the end of your callback, so the callback closes over it and keeps it in scope
00:48 Grinnz but make sure you're referencing the outer $ua variable so it gets closed over
00:48 Grinnz not the one passed in args
00:50 cng Now, where to find some spare brain cells to remember that. Otherwise it’s bound to bite me in the future. To confirm, in example from eday, the *outer* $ua needs to stay in scope within the callback, correct?
00:52 marty joined #mojo
01:59 Grinnz cng: yes. https://metacpan.org/pod/Mojolicious::Guides::FAQ#What-does-%22Premature-connection-close%22-mean?
01:59 Grinnz https://metacpan.org/pod/Mojolicious::Plugin::DefaultHelpers#delay does a similar thing with $tx
01:59 Grinnz https://metacpan.org/source/SRI/Mojolicious-7.31/lib/Mojolicious/Plugin/DefaultHelpers.pm#L80-85
02:05 eday Grinnz: ahh, perfect. thanks! works now as expected
02:06 cng Grinnz: thanks for the links, reading now
02:07 cng To be clear, the `undef $tx` statement is causing the closure?
02:08 Grinnz right. it would do the same if it just said $tx, but the undef is more explicit and stuff
02:09 cng yep, ta
02:43 noganex joined #mojo
02:48 arcanez why isn't there a Mojo module to convert an NFLOG packet to an Ethernet packet so I can look at the packet in nDPI *sigh*
03:04 mgrimes joined #mojo
03:30 aborazmeh joined #mojo
03:47 mgrimes joined #mojo
04:04 dboehmer_ joined #mojo
05:00 inokenty-w joined #mojo
05:07 mgrimes joined #mojo
05:41 dod joined #mojo
05:48 dod joined #mojo
05:48 dod joined #mojo
06:30 yamum joined #mojo
06:55 AndrewIsh joined #mojo
07:17 Vandal joined #mojo
07:28 trone joined #mojo
07:35 dod joined #mojo
08:00 mgrimes joined #mojo
08:08 mgrimes joined #mojo
08:33 osfabibisi joined #mojo
08:43 renormalist joined #mojo
08:43 rshadow joined #mojo
09:00 cosimo joined #mojo
09:06 prg joined #mojo
09:11 vytas joined #mojo
09:48 phillipadsmith joined #mojo
09:48 TBSliver joined #mojo
11:21 tchaves joined #mojo
11:45 abracadaniel joined #mojo
11:57 stryx` joined #mojo
12:13 nic my cpu cores thank you for morbo + inotify
12:31 dod joined #mojo
13:08 q_gone joined #mojo
13:08 gryphon joined #mojo
13:13 tchaves1 joined #mojo
13:23 ashimema joined #mojo
13:29 gizmomathboy joined #mojo
13:57 PryMar56 joined #mojo
13:58 tchaves1 joined #mojo
14:33 PopeFelix joined #mojo
14:43 augensalat joined #mojo
14:44 esh joined #mojo
14:45 Trick14 joined #mojo
14:46 stephan48 joined #mojo
14:46 ksmadsen joined #mojo
14:47 Pyritic joined #mojo
14:49 Zx3 joined #mojo
14:50 dotan_convos joined #mojo
14:52 crab joined #mojo
14:53 dabudabu joined #mojo
14:54 PopeFelix joined #mojo
14:54 simbabque joined #mojo
14:54 rshadow joined #mojo
14:55 Andreas joined #mojo
14:56 renormalist joined #mojo
14:57 zivester joined #mojo
15:00 eseyman joined #mojo
15:00 disputin joined #mojo
15:01 omega joined #mojo
15:01 trone joined #mojo
15:10 miller joined #mojo
15:39 rshadow joined #mojo
15:42 disputin joined #mojo
15:42 stryx` joined #mojo
15:46 yysachinyy joined #mojo
15:52 maschine joined #mojo
16:02 gryphon joined #mojo
16:17 maschine Is it possible to mark cookies with a secure flag using Mojolicious::Controller session?
16:17 maschine I don't see anything about it in the documentation
16:18 maschine I am only using HTTPS but my cookies are marked to use any connection which leaves them open to attack
16:18 pink_mist there's a method on the cookie, not a method on the controller
16:19 pink_mist https://metacpan.org/pod/Mojo::Cookie::Response#secure
16:20 Grinnz https://metacpan.org/pod/Mojolicious::Sessions#secure
16:20 Grinnz that's where you'd set it for session cookies
16:20 Grinnz app->sessions
16:20 purl app->sessions is simply a component that can be replaced
16:20 pink_mist oh, right, he did mention a session ... completely missed that
16:21 rshadow joined #mojo
16:23 stryx` joined #mojo
16:26 howitdo joined #mojo
16:33 maschine I guess actually I'm using a Mojolicious Lite default helper for sessions.  It works pretty well, too bad you can't set that one flag.  I liked not having to manually store and load the session data
16:34 pink_mist wtf
16:34 pink_mist you can
16:34 pink_mist Grinnz already showed you how
16:36 fitnerd joined #mojo
16:36 maschine with this?  http://mojolicious.org/perldoc/Mojolicious/Controller#session
16:37 pink_mist did you read at all what he said?
16:37 pink_mist try re-reading
16:38 pink_mist though, sure, why not?
16:38 maschine I think I understand now - I would set that flag at the beginning of my app, and then it would set all of my cookies that way after that?
16:40 Grinnz just session cookies
16:40 Grinnz you'd need to set the flag on any cookies you set yourself
16:40 maschine yeah, I'm not setting any myself
16:41 Grinnz and no, not with the session method
16:41 Grinnz app->sessions->secure(1) in Mojo::Lite or $self->sessions->secure(1) in full app startup
16:41 Grinnz the controller session method is for setting session data inside the session cookie
16:42 Grinnz / accessing
16:42 Grinnz the Mojolicious::Sessions object controls how the cookie is set
16:44 dod joined #mojo
16:45 maschine right, what I meant was all I needed to do was set "app->sessions->secure(1);"
16:45 maschine thanks for that, sorry if I sound dumb :p
16:45 maschine I think I comprehend about 1% of what Mojo can do
16:45 maschine anyway it worked :)
16:47 maschine and I'm still using the Controller session method
16:51 jberger app->sessions determines how mojo handles the session cookies
16:51 jberger $c->session is the data for the current transaction's session data
16:51 jberger related, but very different
17:54 Phil21 joined #mojo
18:11 tchaves joined #mojo
18:36 stryx` joined #mojo
18:38 dod joined #mojo
18:43 disputin joined #mojo
18:51 mcsnolte joined #mojo
18:54 disputin joined #mojo
19:16 mishanti1 joined #mojo
19:20 itaipu joined #mojo
19:26 itaipu joined #mojo
20:07 yamum I see a couple of REST plugins on cpan, any opinions on which is nicer?
20:08 rshadow joined #mojo
20:14 jberger yamum: I use Mojolicious::Plugin::OpenAPI
20:39 dikim joined #mojo
20:52 yamum jberger: Is it any good?
20:54 pink_mist he recommended it
20:55 pink_mist why would he recommend something that was no good?
21:00 stryx` joined #mojo
21:03 nic yamum: Yes, it's highly regarded
21:03 nic I think I meant 'regarded highly'
21:07 yamum either way.
21:08 yamum nic: I use a lot of things at work that I would claim to use but not say they're life changing.
21:09 nic not sure what the point is there
21:16 yamum I think the main point here is that I don't know how to tab-complete the right person :S
21:17 yamum anyway, I'll just have a look at that module.
21:30 jabberwok Given the state of "auto-correct" and tab-completion, would any sane person get into a "self driving car" ?
21:32 nic of course!  We need to eliminate the scope for human error
21:32 nic (by eliminating all the humans by way of 'self driving cars', snigger)
21:33 jabberwok "Mall, please." "Sorry, you previously had an Unapproved Thought. You are being taken to the Re-Educational Institute. Do not attempt to leave the vehicle..."
21:36 mojo joined #mojo
21:37 nic ok, while we're way off topic...   until relatively recently (let's say 30 yrs ago) parents and others believed that the parents got to decide what was right for their children.  Then it was clarified that children are citizens, protected by the state, with their own rights, and parents are merely their guardians, not their controllers.  I sometimes ponder whether the same is happening with...
21:37 nic ...motor vehicles
21:38 nic You'll have to ask your car whether it's ok to go on a 2 hr drive, and be prepared that the answer might be, "No, not today"
21:40 nic Actually, for me that would be full-circle.  Back in the day I had a Ford Fiesta that was like that
21:41 jabberwok Down, is a good direction
21:50 jabberwok back more to topic, have been fiddling with Beam::Wire and seeing how best to build complete deployments of a Mojo app with that and perhaps Docker.  seems like a good way to build test and staging environments the same as the 'real' one later
22:49 maschine joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary