正在显示
2 个修改的文件
包含
20 行增加
和
7 行删除
| @@ -1102,6 +1102,7 @@ Winlin | @@ -1102,6 +1102,7 @@ Winlin | ||
| 1102 | [bug #485]: https://github.com/simple-rtmp-server/srs/issues/485 | 1102 | [bug #485]: https://github.com/simple-rtmp-server/srs/issues/485 |
| 1103 | [bug #495]: https://github.com/simple-rtmp-server/srs/issues/495 | 1103 | [bug #495]: https://github.com/simple-rtmp-server/srs/issues/495 |
| 1104 | [bug #497]: https://github.com/simple-rtmp-server/srs/issues/497 | 1104 | [bug #497]: https://github.com/simple-rtmp-server/srs/issues/497 |
| 1105 | +[bug #448]: https://github.com/simple-rtmp-server/srs/issues/448 | ||
| 1105 | [bug #475]: https://github.com/simple-rtmp-server/srs/issues/475 | 1106 | [bug #475]: https://github.com/simple-rtmp-server/srs/issues/475 |
| 1106 | [bug #458]: https://github.com/simple-rtmp-server/srs/issues/458 | 1107 | [bug #458]: https://github.com/simple-rtmp-server/srs/issues/458 |
| 1107 | [bug #454]: https://github.com/simple-rtmp-server/srs/issues/454 | 1108 | [bug #454]: https://github.com/simple-rtmp-server/srs/issues/454 |
| @@ -447,37 +447,49 @@ int SrsHttpHooks::do_post(SrsHttpClient* hc, std::string url, std::string req, i | @@ -447,37 +447,49 @@ int SrsHttpHooks::do_post(SrsHttpClient* hc, std::string url, std::string req, i | ||
| 447 | // ensure the http status is ok. | 447 | // ensure the http status is ok. |
| 448 | // https://github.com/simple-rtmp-server/srs/issues/158 | 448 | // https://github.com/simple-rtmp-server/srs/issues/158 |
| 449 | if (code != SRS_CONSTS_HTTP_OK) { | 449 | if (code != SRS_CONSTS_HTTP_OK) { |
| 450 | - return ERROR_HTTP_STATUS_INVLIAD; | 450 | + ret = ERROR_HTTP_STATUS_INVLIAD; |
| 451 | + srs_error("invalid response status=%d. ret=%d", code, ret); | ||
| 452 | + return ret; | ||
| 451 | } | 453 | } |
| 452 | 454 | ||
| 455 | + // should never be empty. | ||
| 453 | if (res.empty()) { | 456 | if (res.empty()) { |
| 454 | - return ERROR_HTTP_DATA_INVLIAD; | 457 | + ret = ERROR_HTTP_DATA_INVLIAD; |
| 458 | + srs_error("invalid empty response. ret=%d", ret); | ||
| 459 | + return ret; | ||
| 455 | } | 460 | } |
| 456 | 461 | ||
| 457 | // parse string res to json. | 462 | // parse string res to json. |
| 458 | SrsJsonAny* info = SrsJsonAny::loads((char*)res.c_str()); | 463 | SrsJsonAny* info = SrsJsonAny::loads((char*)res.c_str()); |
| 464 | + if (!info) { | ||
| 465 | + ret = ERROR_HTTP_DATA_INVLIAD; | ||
| 466 | + srs_error("invalid response %s. ret=%d", res.c_str(), ret); | ||
| 467 | + return ret; | ||
| 468 | + } | ||
| 459 | SrsAutoFree(SrsJsonAny, info); | 469 | SrsAutoFree(SrsJsonAny, info); |
| 460 | 470 | ||
| 461 | - // if res is number of error code | 471 | + // response error code in string. |
| 462 | if (!info->is_object()) { | 472 | if (!info->is_object()) { |
| 463 | if (res != SRS_HTTP_RESPONSE_OK) { | 473 | if (res != SRS_HTTP_RESPONSE_OK) { |
| 464 | - return ERROR_HTTP_DATA_INVLIAD; | 474 | + ret = ERROR_HTTP_DATA_INVLIAD; |
| 475 | + srs_error("invalid response number %s. ret=%d", res.c_str(), ret); | ||
| 476 | + return ret; | ||
| 465 | } | 477 | } |
| 466 | return ret; | 478 | return ret; |
| 467 | } | 479 | } |
| 468 | 480 | ||
| 469 | - // if res is json obj, like: {"code": 0, "data": ""} | 481 | + // response standard object, format in json: {"code": 0, "data": ""} |
| 470 | SrsJsonObject* res_info = info->to_object(); | 482 | SrsJsonObject* res_info = info->to_object(); |
| 471 | SrsJsonAny* res_code = NULL; | 483 | SrsJsonAny* res_code = NULL; |
| 472 | if ((res_code = res_info->ensure_property_integer("code")) == NULL) { | 484 | if ((res_code = res_info->ensure_property_integer("code")) == NULL) { |
| 473 | ret = ERROR_RESPONSE_CODE; | 485 | ret = ERROR_RESPONSE_CODE; |
| 474 | - srs_error("res code error, ret=%d", ret); | 486 | + srs_error("invalid response without code, ret=%d", ret); |
| 475 | return ret; | 487 | return ret; |
| 476 | } | 488 | } |
| 477 | 489 | ||
| 478 | if ((res_code->to_integer()) != ERROR_SUCCESS) { | 490 | if ((res_code->to_integer()) != ERROR_SUCCESS) { |
| 479 | ret = ERROR_RESPONSE_CODE; | 491 | ret = ERROR_RESPONSE_CODE; |
| 480 | - srs_error("res code error, ret=%d, code=%d", ret, code); | 492 | + srs_error("error response code=%d. ret=%d", res_code->to_integer(), ret); |
| 481 | return ret; | 493 | return ret; |
| 482 | } | 494 | } |
| 483 | 495 |
-
请 注册 或 登录 后发表评论