Skip to content

Commit

Permalink
修复微信聊天过程中遇到"对方正在输入"提示时,接收消息接口响应异常("Bad response start-line"),引起程序终止的严…
Browse files Browse the repository at this point in the history
…重bug
  • Loading branch information
hexsum committed Apr 10, 2019
1 parent 68cb469 commit 2a7e26d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/Mojo/Weixin/Plugin/Openwx.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sub call{
$client->stdout_line($client->to_json($post_json)) if $data->{post_stdout};
if(defined $data->{post_api}){
my($data,$ua,$tx) = $client->http_post($data->{post_api},{ua_connect_timeout=>5,ua_request_timeout=>5,ua_inactivity_timeout=>5,ua_retry_times=>1},json=>$post_json);
if($tx->result->is_success){
if($tx->res->is_success){
$client->debug("插件[".__PACKAGE__ ."]事件[".$event . "](@args)上报成功");
}
else{
Expand All @@ -62,7 +62,7 @@ sub call{
$client->stdout_line($client->to_json($post_json)) if $data->{post_stdout};
if(defined $data->{post_api}){
my($data,$ua,$tx) = $client->http_post($data->{post_api},json=>$post_json);
if($tx->result->is_success){
if($tx->res->is_success){
$client->debug("插件[".__PACKAGE__ ."]事件[".$event . "]上报成功");
}
else{
Expand All @@ -84,7 +84,7 @@ sub call{
$client->stdout_line($client->to_json($post_json)) if $data->{post_stdout};
$client->http_post($data->{post_api},json=>$post_json,sub{
my($data,$ua,$tx) = @_;
if($tx->result->is_success){
if($tx->res->is_success){
$client->debug("插件[".__PACKAGE__ ."]事件[".$event."]上报成功");
}
else{
Expand All @@ -103,7 +103,7 @@ sub call{
$client->stdout_line($client->to_json($post_json)) if $data->{post_stdout};
$client->http_post($data->{post_api},json=>$post_json,sub{
my($data,$ua,$tx) = @_;
if($tx->result->is_success){
if($tx->res->is_success){
$client->debug("插件[".__PACKAGE__ ."]事件[".$event."]上报成功");
}
else{
Expand All @@ -123,7 +123,7 @@ sub call{
$client->stdout_line($client->to_json($post_json)) if $data->{post_stdout};
$client->http_post($data->{post_api},json=>$post_json,sub{
my($data,$ua,$tx) = @_;
if($tx->result->is_success){
if($tx->res->is_success){
$client->debug("插件[".__PACKAGE__ ."]事件[".$event."]上报成功");
}
else{
Expand All @@ -141,7 +141,7 @@ sub call{
$client->stdout_line($client->to_json($post_json)) if $data->{post_stdout};
$client->http_post($data->{post_api},json=>$post_json,sub{
my($data,$ua,$tx) = @_;
if($tx->result->is_success){
if($tx->res->is_success){
$client->debug("插件[".__PACKAGE__ ."]事件[".$event."]上报成功");
}
else{
Expand All @@ -167,7 +167,7 @@ sub call{
$client->stdout_line($client->to_json($post_json)) if $data->{post_stdout};
$client->http_post($data->{post_api},json=>$post_json,sub{
my($data,$ua,$tx) = @_;
if($tx->result->is_success){
if($tx->res->is_success){
$client->debug( $tx->res->body );
if($tx->res->headers->content_type =~m#(text|application)/json#){
#文本类的返回结果必须是json字符串
Expand Down Expand Up @@ -211,7 +211,7 @@ sub call{
$client->stdout_line($client->to_json($post_json)) if $data->{post_stdout};
$client->http_post($data->{post_api},json=>$post_json,sub{
my($data,$ua,$tx) = @_;
if($tx->result->is_success){
if($tx->res->is_success){
$client->debug("插件[".__PACKAGE__ ."]发送消息[".$msg->id."]上报成功");
if($tx->res->headers->content_type =~m#text/json|application/json#){
#文本类的返回结果必须是json字符串
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Weixin/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ sub _http_request{
my($ua,$tx) = @_;
_ua_debug($self,$ua,$tx,\%opt,0) if $opt{ua_debug};
$self->save_cookie();
if(defined $tx and $tx->result->is_success){
if(defined $tx and $tx->res->is_success){
my $r = $opt{json}?$self->from_json($tx->res->body):$tx->res->body;
$cb->($r,$ua,$tx);
}
Expand Down Expand Up @@ -148,7 +148,7 @@ sub _http_request{
}
_ua_debug($self,$ua,$tx,\%opt,1) if $opt{ua_debug};
$self->save_cookie();
if(defined $tx and $tx->result->is_success){
if(defined $tx and $tx->res->is_success){
my $r = $opt{json}?$self->from_json($tx->res->body):$tx->res->body;
$cb->($r,$ua,$tx) if defined $cb;
return wantarray?($r,$self->ua,$tx):$r;
Expand Down

0 comments on commit 2a7e26d

Please sign in to comment.