On Sunday, December 14, 2014 9:43:12 AM UTC-5, sri wrote:
>
> I replaced a blocking Mojo::UserAgent call with an 
>> asynchronous version, and the associated call back/closure. 
>>
>
> This is still blocking, you've just redirected the content stream from an 
> asset object into a closure.
>

This is a  wording error on my part, I don't really care about the 
blocking/non-blocking nature, I care more about the streaming client side, 
which is for the most part, working.

Where it falls down is on error handling.  If I run a query I expect to 
fail using curl, I can see the header and content failure I want to capture 
in an event.


landman@metal:~$ curl -v -G 'hp=scalable' --data-urlencode "q=select * from 
metal.tcpinfo.udperrs1 limit 10"
* Adding handle: conn: 0xa9ffa0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0xa9ffa0) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 8086 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8086 (#0)
> GET 
/db/metrics/series?u=scalable&p=scalable&q=select%20%2A%20from%20metal.tcpinfo.udperrs1%20limit%2010
 
HTTP/1.1
> User-Agent: curl/7.33.0
> Host: localhost:8086
> Accept: */*
> 
< HTTP/1.1 400 Bad Request
< Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, 
Accept
< Access-Control-Allow-Methods: GET, POST, PUT, DELETE
< Access-Control-Allow-Origin: *
< Access-Control-Max-Age: 2592000
< Content-Type: text/plain
< X-Influxdb-Version: InfluxDB v0.8.8 (git: afde71e) (leveldb: 1.15)
< Date: Tue, 30 Dec 2014 18:38:11 GMT
< Content-Length: 44
< 
* Connection #0 to host localhost left intact
Couldn't find series: metal.tcpinfo.udperrs1


I want to get that '400 Bad request' and the 'Couldn't find ...' string.  I 
am guessing I need to do something like this:

my @message;

$tx->res->headers->unsubscribe($EVENT1)
->on($EVENT1 => sub {
  my ($msg,$code) = @_;
push @message,{msg => $msg, rc => $code};
});
 
But I don't know what event I should be using for $EVENT1.  Looking at 
Mojo::Event.  Would this be the progress event?  

I stepped through the code and looked at the trace through the $ret = 
$ua->start($tx) and noticed at the end, the $ret->res->code returned 200, 
even though it really is 400.  Any hints on how to subscribe to the correct 
response bits?  

Thanks!


> --
> sebastian 
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to