Re: non-blocking http call and glib



Can anyone try this code and post if there's any output? I don't get any output. I suspect something is wrong on the lib level.
 
I'm on Windows 10 with Strawberry Perl 5.24 64bit btw.

======

#!/usr/bin/perl

use strict;
use warnings;

use IO::Async::Loop::Glib;
use Net::Async::HTTP;
use Gtk2 qw( -init );

my $loop = IO::Async::Loop::Glib->new;

my $ua = Net::Async::HTTP->new;
$loop->add( $ua );

recognition();

Gtk2->main;



sub recognition
{
   my $f = $ua->POST(
      "http://www.google.com",
      [
         test => "params",
         go => "here",
      ]
   )->then(
      # success
      sub {
         my ( $response ) = @_;

         print "response is: $response\n";
         Future->done;
      },

      # failure
      sub {
         my ( $error ) = @_;

         print "failure is $error\n";
         Future->done;
      },
   );

   $ua->adopt_future( $f );
}

On Mon, Feb 27, 2017 at 12:04 AM, Grant McLean <grant mclean net nz> wrote:
You might want to look at libsoup - the Gnome library for HTTP requests.
I think the latest Perl bindings are here:

  https://metacpan.org/release/HTTP-Soup-Gnome

Regards
Grant

On Sun, 2017-02-26 at 23:41 +0200, haratron wrote:
> I'm trying to do a non blocking call to an http server with
> Mojo::UserAgent so that it doesn't block the Gtk GUI while it's
> waiting for the response. I want to do the request and once the
> results are back to update the GUI. I'm confused on how to do this.
> I'm on win32, here's the code so far.
>
>
> http://pastebin.ca/3772676
>
>
> This code makes the program hang and they told me on #perl that it's
> because I'm using two loops, one from Gtk and one from Mojo.
> What is the correct way of doing this?
>
>
> _______________________________________________
> gtk-perl-list mailing list
> gtk-perl-list gnome org
> https://mail.gnome.org/mailman/listinfo/gtk-perl-list


_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]