Re: [Mojolicious] Mojolicious-8.04

2018-10-28 Thread Dan Book
This error comes from passing extra options to a 'has' attribute
declaration. Previously it took two arguments and ignored the rest. Now it
uses the rest as options and only the 'weak' option is allowed.

-Dan

On Sun, Oct 28, 2018 at 3:45 PM Jan Eskilsson 
wrote:

> Hi All
>
> Today we upgraded our test system from Mojolicious-8 to Mojolicious-8.04
> and we got a bit of a problem.
>
> When we try to start Morbo we get this error
> Odd number of elements in hash assignment at
> /opt/ActivePerl-5.24/site/lib/Mojo/Base.pm line 27.
> Can't load application from file
> "/home/jan/Project/mateorit_microservice/script/mateorit_microservice":
> Unsupported attribute option at
> /home/jan/Project/mateorit_microservice/script/../lib/MateoritMicroservice.pm
> line 6.
> Compilation failed in require at
> /home/jan/Project/mateorit_microservice/script/../lib/MateoritMicroservice.pm
> line 6.
>
> ./lib/MateoritMicroservice.pm line 6.  looks like this,
>  use MateoritMicroservice::Model::Messages;
>
> and in MateoritMicroservice::Model::Messages,
>
> package MateoritMicroservice::Model::Messages;
> use Mojo::Base -base;
>
> and the error seems to originate from this line in Mojo::Base::attr
>   Carp::croak 'Unsupported attribute option' if grep { $_ ne 'weak' } keys
> %kv;
>
> What are we doing wrong here ? adding use Mojo::Base -base, -weak;  does
> not seem to change anything.
>
> everything worked fine using Mojolicious-8 before the upgrade so i guess
> we are missing something here.
>
>
> Thank you in advance.
>
> Best Regards
> Jan
>
>
> --
> Titles mean nothing.  The one with a servant's heart is the leader.
>
> Please consider the environment before you print this email.
>
> All incoming and outgoing emails and any attachments are subjected to a
> virus scanner and are believed to be free of any virus, or any other defect
> which might affect any computer or IT system into which they are received
> and opened. Therefore, it is the responsibility of the recipient to ensure
> that they are virus free and no responsibility is accepted by Jan Eskilsson
>  for any loss or damage arising in any way from receipt or use thereof.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mojolicious+unsubscr...@googlegroups.com.
> To post to this group, send email to mojolicious@googlegroups.com.
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[Mojolicious] Mojolicious-8.04

2018-10-28 Thread Jan Eskilsson
Hi All

Today we upgraded our test system from Mojolicious-8 to Mojolicious-8.04
and we got a bit of a problem.

When we try to start Morbo we get this error
Odd number of elements in hash assignment at
/opt/ActivePerl-5.24/site/lib/Mojo/Base.pm line 27.
Can't load application from file
"/home/jan/Project/mateorit_microservice/script/mateorit_microservice":
Unsupported attribute option at
/home/jan/Project/mateorit_microservice/script/../lib/MateoritMicroservice.pm
line 6.
Compilation failed in require at
/home/jan/Project/mateorit_microservice/script/../lib/MateoritMicroservice.pm
line 6.

./lib/MateoritMicroservice.pm line 6.  looks like this,
 use MateoritMicroservice::Model::Messages;

and in MateoritMicroservice::Model::Messages,

package MateoritMicroservice::Model::Messages;
use Mojo::Base -base;

and the error seems to originate from this line in Mojo::Base::attr
  Carp::croak 'Unsupported attribute option' if grep { $_ ne 'weak' } keys
%kv;

What are we doing wrong here ? adding use Mojo::Base -base, -weak;  does
not seem to change anything.

everything worked fine using Mojolicious-8 before the upgrade so i guess we
are missing something here.


Thank you in advance.

Best Regards
Jan


-- 
Titles mean nothing.  The one with a servant's heart is the leader.

Please consider the environment before you print this email.

All incoming and outgoing emails and any attachments are subjected to a
virus scanner and are believed to be free of any virus, or any other defect
which might affect any computer or IT system into which they are received
and opened. Therefore, it is the responsibility of the recipient to ensure
that they are virus free and no responsibility is accepted by Jan Eskilsson
 for any loss or damage arising in any way from receipt or use thereof.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


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, 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 
> , url_escape 
>  is being applied:
>
> Percent encode unsafe characters in string as described in RFC 3986 
> , the pattern used defaults to 
> ^A-Za-z0-9\-._~.
>
>
> Reading the code for to_string in Mojo::Parameters, I see no way around 
> this.  It would seem that Yahoo Finance is not RFC 3986 compliant.  The 
> question that needs to be asked then is, "Is it possible for Mojo::URL to 
> customize the characters that are considered unsafe?"  I don't know super 
> advanced Perl like this, but maybe it's possible to override a function and 
> make Mojo::Util::url_escape not actually escape the string?
>
> There might be a more advanced way to build your transaction, one that 
> doesn't operate on a Mojo::URL object which will ultimately apply 
> url_escape without question -- but I wouldn't know it.
>
> Anyway, from what I can see, there's not a solution to your problem.  :(
>
>
> On Sun, Oct 28, 2018 at 11:49 AM Sylvain Thibault  > wrote:
>
>> 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=l86,l84,p20=parent.yfs_u1f=parent.yfs_mktmcb=parent.yfs_gencb=1=en-US=US=0'
>>
>>
>> #! /usr/bin/env perl
>> use Mojo::UserAgent;
>> use feature qw(say);
>>
>> $| = 1;
>>
>> # Accept responses of indefinite size
>> my $ua = Mojo::UserAgent->new(max_response_size => 0);
>> $ua->inactivity_timeout(0);
>>
>> my $url_raw
>> # Symbol ^GSPC returns NOT FOUND
>> #  = 'https://streamerapi.finance.yahoo.com/streamer/1.0?s=
>> ^GSPC=l86,l84,p20=parent.yfs_u1f=parent.yfs_mktmcb=parent.yfs_gencb=1=en-US=US=0';
>>   = '
>> https://streamerapi.finance.yahoo.com/streamer/1.0?s=SPY=l86,l84,p20=parent.yfs_u1f=parent.yfs_mktmcb=parent.yfs_gencb=1=en-US=US=0
>> ';
>>
>>
>> # Build a normal transaction
>> my $tx = $ua->build_tx(
>>   GET => $url_raw,
>>   => {Accept => '*/*'}
>> );
>>
>> # Remove caret encoding... results is not found... ???
>> say $tx->req->to_string;
>>
>> # Replace "read" events to disable default content parser
>> $tx->res->content->unsubscribe('read')->on(
>>   read => sub {
>> my ($content, $bytes) = @_;
>> say "Streaming: $bytes";
>>   }
>> );
>>
>> # Process transaction
>> $tx = $ua->start($tx);
>>
>>
>> say "done";
>>
>>
>>
>> On Saturday, October 27, 2018 at 5:38:43 PM UTC-6, Sylvain Thibault wrote:
>>>
>>> Given URL https://somehost.com.com/streamer/1.0?s=^GSPC
>>>
>>> When doing a GET, Mojo::UserAgent encodes the caret '^' as %5E
>>> The server returns NOT FOUND.
>>>
>>> So this transaction from Mojo::UserAgent returns NOT FOUND:
>>>
>>> GET /streamer/1.0?s=%5EGSPC=l86,l84,p20 HTTP/1.1
>>> Host: somehost.com
>>> Accept: */*
>>> User-Agent: Mojolicious (Perl)
>>> Content-Length: 0
>>>
>>> This transaction using curl with the caret not encoded returns the 
>>> desired output:
>>>
>>> GET /streamer/1.0?s=^GSPC=l86,l84,p20 HTTP/1.1
>>> Host: s omehost.com
>>> User-Agent: curl/7.61.1
>>> Accept: */*
>>>
>>> How does one send a caret '^' in a URL without encoding it to %5E ?
>>>
>>> Using a symbol without a caret works great in the Mojo::UserAgent 
>>> version of the code.
>>>
>>> Thanks,
>>>
>>> Sylvain Thibault 
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to mojolicious...@googlegroups.com .
>> To post to this group, send email to mojol...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/mojolicious.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


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
, url_escape
 is being applied:

Percent encode unsafe characters in string as described in RFC 3986
, the pattern used defaults to
^A-Za-z0-9\-._~.


Reading the code for to_string in Mojo::Parameters, I see no way around
this.  It would seem that Yahoo Finance is not RFC 3986 compliant.  The
question that needs to be asked then is, "Is it possible for Mojo::URL to
customize the characters that are considered unsafe?"  I don't know super
advanced Perl like this, but maybe it's possible to override a function and
make Mojo::Util::url_escape not actually escape the string?

There might be a more advanced way to build your transaction, one that
doesn't operate on a Mojo::URL object which will ultimately apply
url_escape without question -- but I wouldn't know it.

Anyway, from what I can see, there's not a solution to your problem.  :(


On Sun, Oct 28, 2018 at 11:49 AM Sylvain Thibault 
wrote:

> 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=l86,l84,p20=parent.yfs_u1f=parent.yfs_mktmcb=parent.yfs_gencb=1=en-US=US=0'
>
>
> #! /usr/bin/env perl
> use Mojo::UserAgent;
> use feature qw(say);
>
> $| = 1;
>
> # Accept responses of indefinite size
> my $ua = Mojo::UserAgent->new(max_response_size => 0);
> $ua->inactivity_timeout(0);
>
> my $url_raw
> # Symbol ^GSPC returns NOT FOUND
> #  = 'https://streamerapi.finance.yahoo.com/streamer/1.0?s=
> ^GSPC=l86,l84,p20=parent.yfs_u1f=parent.yfs_mktmcb=parent.yfs_gencb=1=en-US=US=0';
>   = '
> https://streamerapi.finance.yahoo.com/streamer/1.0?s=SPY=l86,l84,p20=parent.yfs_u1f=parent.yfs_mktmcb=parent.yfs_gencb=1=en-US=US=0
> ';
>
>
> # Build a normal transaction
> my $tx = $ua->build_tx(
>   GET => $url_raw,
>   => {Accept => '*/*'}
> );
>
> # Remove caret encoding... results is not found... ???
> say $tx->req->to_string;
>
> # Replace "read" events to disable default content parser
> $tx->res->content->unsubscribe('read')->on(
>   read => sub {
> my ($content, $bytes) = @_;
> say "Streaming: $bytes";
>   }
> );
>
> # Process transaction
> $tx = $ua->start($tx);
>
>
> say "done";
>
>
>
> On Saturday, October 27, 2018 at 5:38:43 PM UTC-6, Sylvain Thibault wrote:
>>
>> Given URL https://somehost.com.com/streamer/1.0?s=^GSPC
>>
>> When doing a GET, Mojo::UserAgent encodes the caret '^' as %5E
>> The server returns NOT FOUND.
>>
>> So this transaction from Mojo::UserAgent returns NOT FOUND:
>>
>> GET /streamer/1.0?s=%5EGSPC=l86,l84,p20 HTTP/1.1
>> Host: somehost.com
>> Accept: */*
>> User-Agent: Mojolicious (Perl)
>> Content-Length: 0
>>
>> This transaction using curl with the caret not encoded returns the
>> desired output:
>>
>> GET /streamer/1.0?s=^GSPC=l86,l84,p20 HTTP/1.1
>> Host: s omehost.com
>> User-Agent: curl/7.61.1
>> Accept: */*
>>
>> How does one send a caret '^' in a URL without encoding it to %5E ?
>>
>> Using a symbol without a caret works great in the Mojo::UserAgent version
>> of the code.
>>
>> Thanks,
>>
>> Sylvain Thibault
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mojolicious+unsubscr...@googlegroups.com.
> To post to this group, send email to mojolicious@googlegroups.com.
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


[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=l86,l84,p20=parent.yfs_u1f=parent.yfs_mktmcb=parent.yfs_gencb=1=en-US=US=0'


#! /usr/bin/env perl
use Mojo::UserAgent;
use feature qw(say);

$| = 1;

# Accept responses of indefinite size
my $ua = Mojo::UserAgent->new(max_response_size => 0);
$ua->inactivity_timeout(0);

my $url_raw
# Symbol ^GSPC returns NOT FOUND
#  = 
'https://streamerapi.finance.yahoo.com/streamer/1.0?s=^GSPC=l86,l84,p20=parent.yfs_u1f=parent.yfs_mktmcb=parent.yfs_gencb=1=en-US=US=0';
  = 
'https://streamerapi.finance.yahoo.com/streamer/1.0?s=SPY=l86,l84,p20=parent.yfs_u1f=parent.yfs_mktmcb=parent.yfs_gencb=1=en-US=US=0'
;


# Build a normal transaction
my $tx = $ua->build_tx(
  GET => $url_raw,
  => {Accept => '*/*'}
);

# Remove caret encoding... results is not found... ???
say $tx->req->to_string;

# Replace "read" events to disable default content parser
$tx->res->content->unsubscribe('read')->on(
  read => sub {
my ($content, $bytes) = @_;
say "Streaming: $bytes";
  }
);

# Process transaction
$tx = $ua->start($tx);


say "done";



On Saturday, October 27, 2018 at 5:38:43 PM UTC-6, Sylvain Thibault wrote:
>
> Given URL https://somehost.com.com/streamer/1.0?s=^GSPC
>
> When doing a GET, Mojo::UserAgent encodes the caret '^' as %5E
> The server returns NOT FOUND.
>
> So this transaction from Mojo::UserAgent returns NOT FOUND:
>
> GET /streamer/1.0?s=%5EGSPC=l86,l84,p20 HTTP/1.1
> Host: somehost.com
> Accept: */*
> User-Agent: Mojolicious (Perl)
> Content-Length: 0
>
> This transaction using curl with the caret not encoded returns the desired 
> output:
>
> GET /streamer/1.0?s=^GSPC=l86,l84,p20 HTTP/1.1
> Host: s omehost.com
> User-Agent: curl/7.61.1
> Accept: */*
>
> How does one send a caret '^' in a URL without encoding it to %5E ?
>
> Using a symbol without a caret works great in the Mojo::UserAgent version 
> of the code.
>
> Thanks,
>
> Sylvain Thibault 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


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

2018-10-28 Thread Stefan Adams
On Sat, Oct 27, 2018 at 6:38 PM Sylvain Thibault 
wrote:

> How does one send a caret '^' in a URL without encoding it to %5E ?
>
> Using a symbol without a caret works great in the Mojo::UserAgent version
> of the code.
>

Being that we're talking about a query parameter, it seems like we're not
dealing with a routing problem.  Can you see from the log if your action
handler is being processed?  Is so, add `warn $c->param('s')` right after
you set $c to the first parameter and then watch STDERR for what's
contained in the 's' parameter.  Do you have any code in your action
handler that returns a 404, such as $c->reply->not_found?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.