- $r = $conn->connect($host, $port);
- if ($r) {
- dbg("Sending '$sort $path HTTP/1.0'") if isdbg('async');
- $conn->send_later("$sort $path HTTP/1.0\n");
-
- my $h = delete $args{Host} || $host;
- my $u = delete $args{'User-Agent'} || "DxSpider;$main::version;$main::build;$^O;$main::mycall";
- my $d = delete $args{data};
-
- $conn->send_later("Host: $h\n");
- $conn->send_later("User-Agent: $u\n");
- while (my ($k,$v) = each %args) {
- $conn->send_later("$k: $v\n");
- }
- $conn->send_later("\n$d") if defined $d;
- $conn->send_later("\n");
- }
+ my $tx = $ua->build_tx($sort => $s);
+ $ua->on(error => sub { $conn->_error(@_); });
+# $tx->on(error => sub { $conn->_error(@_); });
+# $tx->on(finish => sub { $conn->disconnect; });
+
+ $ua->on(start => sub {
+ my ($ua, $tx) = @_;
+ while (my ($k, $v) = each %args) {
+ dbg("AsyncMsg: attaching header $k: $v") if isdbg('async');
+ $tx->req->headers->header($k => $v);
+ }
+ if (defined $data) {
+ dbg("AsyncMsg: body ='$data'") if isdbg('async');
+ $tx->req->body($data);
+ }
+ });