Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Stefan Adams
On Wed, Oct 31, 2018 at 9:34 PM Sylvain Thibault wrote: > As suggested, here is a working solution using a Role::Tiny role to > modify/override Mojo::Parameters::to_string so that it does not escape the > caret '^' character. > Feel free to comment/criticize. > That looks terrific to me and pret

[Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Sylvain Thibault
As suggested, here is a working solution using a Role::Tiny role to modify/override Mojo::Parameters::to_string so that it does not escape the caret '^' character. Feel free to comment/criticize. Thank you all for your valuable input, this was enlightening. use Mojo::UserAgent; use FindBin qw($

[Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Sylvain Thibault
As suggested, here is a working solution using a Role::Tiny role to modify Mojo::Parameters::to_string so that it does not escape the caret '^' character. Feel free to comment/criticize. Thank you all for you valuable input, this was enlightening. use Mojo::UserAgent; use FindBin qw($Bin); use

[Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Sylvain Thibault
Can somebody describe with a little more detail how one would go about using a role to modify Mojo::Parameters::to_string and using it with something like $tx->req->url->query->with_roles('+Unescaped') ? I am looking at Joel Berger's blog post: https://mojolicious.io/blog/2017/12/13/day-13-more

Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Stefan Adams
On Wed, Oct 31, 2018 at 12:19 PM Dan Book wrote: > Mojo::Collection and Mojo::File are not hash-based objects so they cannot > use Mojo::Base, thus they implement with_roles themselves. Mojo::Base based > objects all say "inherits all methods from Mojo::Base" or a subclass of > that. > This is r

Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Dan Book
Mojo::Collection and Mojo::File are not hash-based objects so they cannot use Mojo::Base, thus they implement with_roles themselves. Mojo::Base based objects all say "inherits all methods from Mojo::Base" or a subclass of that. -Dan On Wed, Oct 31, 2018 at 12:42 PM Stefan Adams wrote: > > > On

Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Stefan Adams
On Wed, Oct 31, 2018 at 11:15 AM Dan Book wrote: > It does have with_roles, it comes from Mojo::Base. > Hmm!! I wondered that!!! But then why isn't it documented like it is for Mojo::Collection and Mojo::File? What difference is there? Gosh, knowing this now opens up a lot of doors for me!!!

Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Dan Book
It does have with_roles, it comes from Mojo::Base. -Dan On Wed, Oct 31, 2018 at 12:10 PM Stefan Adams wrote: > > > On Wed, Oct 31, 2018 at 10:48 AM sri wrote: > >> Poking into internals usually means one day you'll get what you asked >>> for, but if there is no other way... >>> >> >> Yes, that

Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Stefan Adams
On Wed, Oct 31, 2018 at 10:48 AM sri wrote: > Poking into internals usually means one day you'll get what you asked for, >> but if there is no other way... >> > > Yes, that is a very dangerous hack, a more sane approach would be to use a > Role::Tiny role modifying > Mojo::Parameters::to_string >

Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread sri
> > I do not know of a non-ugly way either but if you are okay with a hacky > and possibly fragile solution you might get away with adding: > > $ua->on(start => sub { >my ($ua, $tx) = @_; >$tx->req->{'start_buffer'} =~ s/([&?]s=)%5E/$1^/o; > }); > > Poking into internals usually means o

Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Sylvain Thibault
Thank you Heiko, This works for me. This case is definitely an outlier. On Wednesday, October 31, 2018 at 5:09:43 AM UTC-6, Heiko Jansen wrote: > > I do not know of a non-ugly way either but if you are okay with a hacky > and possibly fragile solution you might get away with adding: > > $ua->on(

Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-31 Thread Heiko Jansen
I do not know of a non-ugly way either but if you are okay with a hacky and possibly fragile solution you might get away with adding: $ua->on(start => sub { my ($ua, $tx) = @_; $tx->req->{'start_buffer'} =~ s/([&?]s=)%5E/$1^/o; }); Poking into internals usually means one day you'll get w

Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-28 Thread Sylvain Thibault
Thanks for that. You would think Yahoo would be RFC 3986 compliant but their services have been on the decline for a while. I don't know how to override Mojo::Util url_escape either. On Sunday, October 28, 2018 at 12:46:36 PM UTC-6, Stefan Adams wrote: > > I see, you are building a client app, n

Re: [Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-28 Thread Stefan Adams
I see, you are building a client app, not a server app -- I missed that detail. And, I see that you want to pass the ^ *without* escaping it. Your URL is getting parsed by Mojo::URL, whose parameters are getting parsed by Mojo::Parameters, and when you get the parameters as a string

[Mojolicious] Re: Mojo::UserAgent URL with caret '^' not encoded

2018-10-28 Thread Sylvain Thibault
Thank you for your response Stefan. Here is the complete code. Symbol SPY works, symbol ^GSPC returns not found . This curl command with the ^GSPC symbol works: curl -s -o - -N -v 'https://streamerapi.finance.yahoo.com/streamer/1.0?s=^GSPC&k=l86,l84,p20&callback=parent.yfs_u1f&mktmcb=parent.y