Two more problems with Mojolicious

Александр Поволоцкий tarkhil at over.ru
Mon Mar 4 19:24:33 UTC 2019


Nope. It did not help in some cases. I'll have to get the bare minimum 
of code to reproduce it, that's not too clear. Most likely, some issue 
between me, Mojo and postgresql...

On 04.03.2019 22:18, Александр Поволоцкий wrote:
> Ok, got the issue. It was only valid with chunk_write. I'll replace in 
> with more common write and see
>
> On 04.03.2019 22:02, Andrey Zelenkov wrote:
>>> On 4 Mar 2019, at 19:06, Александр Поволоцкий <tarkhil at over.ru> wrote:
>>>
>>> My program outputs JSON. decode_json works fine with HTTP, to_json 
>>> is required for PSGI.
>> [..]
>>
>> Hi Alex,
>>
>> I’ve tried to use encode_json and to_json and they both work fine.
>>
>> For encode_json:
>>
>> ===
>> use Mojolicious::Lite;
>> use Mojo::JSON qw(decode_json encode_json to_json);
>>
>> get '/' => sub {
>>    my $c = shift;
>>    $c->write(encode_json({test => 'Привет I ♥ Mojolicious!'}));
>> };
>>
>> app->start;
>> ===
>>
>> I've got response:
>>
>> ===
>> HTTP/1.1 200 OK
>> Date: Mon, 04 Mar 2019 18:53:21 GMT
>> Server: Unit/1.8.0
>> Connection: close
>> Transfer-Encoding: chunked
>>
>> 2a
>> {"test":"Привет I ♥ Mojolicious!"}
>> 0
>> ===
>>
>> and for to_json:
>>
>> ===
>> use Mojolicious::Lite;
>> use Mojo::JSON qw(decode_json encode_json to_json);
>>
>> get '/' => sub {
>>    my $c = shift;
>>    $c->write(to_json({test => 'Привет I ♥ Mojolicious!'}));
>> };
>>
>> app->start;
>> ===
>>
>> I've got response:
>>
>> ===
>> HTTP/1.1 200 OK
>> Date: Mon, 04 Mar 2019 18:54:24 GMT
>> Server: Unit/1.8.0
>> Connection: close
>> Transfer-Encoding: chunked
>>
>> 2a
>> {"test":"Привет I ♥ Mojolicious!"}
>> 0
>> ===
>>
>>
>> Could you please provide more information about
>> how you try to use to_json?
>>
>> -- 
>> Andrey Zelenkov
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> unit mailing list
>> unit at nginx.org
>> https://mailman.nginx.org/mailman/listinfo/unit
> _______________________________________________
> unit mailing list
> unit at nginx.org
> https://mailman.nginx.org/mailman/listinfo/unit


More information about the unit mailing list