正在显示
2 个修改的文件
包含
23 行增加
和
7 行删除
| @@ -110,7 +110,12 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -110,7 +110,12 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 110 | << SRS_JFIELD_STR("requests", "the request itself, for http debug") << SRS_JFIELD_CONT | 110 | << SRS_JFIELD_STR("requests", "the request itself, for http debug") << SRS_JFIELD_CONT |
| 111 | << SRS_JFIELD_STR("vhosts", "dumps vhost to json") << SRS_JFIELD_CONT | 111 | << SRS_JFIELD_STR("vhosts", "dumps vhost to json") << SRS_JFIELD_CONT |
| 112 | << SRS_JFIELD_STR("streams", "dumps streams to json") << SRS_JFIELD_CONT | 112 | << SRS_JFIELD_STR("streams", "dumps streams to json") << SRS_JFIELD_CONT |
| 113 | - << SRS_JFIELD_STR("errors", "always return an error 100.") | 113 | + << SRS_JFIELD_ORG("test", SRS_JOBJECT_START) |
| 114 | + << SRS_JFIELD_STR("requests", "show the request info") << SRS_JFIELD_CONT | ||
| 115 | + << SRS_JFIELD_STR("errors", "always return an error 100") << SRS_JFIELD_CONT | ||
| 116 | + << SRS_JFIELD_STR("redirects", "always redirect to /api/v1/test/errors") << SRS_JFIELD_CONT | ||
| 117 | + << SRS_JFIELD_STR(".vhost.", "http vhost for error.srs.com/api/v1/test/errors") | ||
| 118 | + << SRS_JOBJECT_END | ||
| 114 | << SRS_JOBJECT_END | 119 | << SRS_JOBJECT_END |
| 115 | << SRS_JOBJECT_END; | 120 | << SRS_JOBJECT_END; |
| 116 | 121 | ||
| @@ -489,7 +494,8 @@ int SrsGoApiError::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -489,7 +494,8 @@ int SrsGoApiError::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 489 | 494 | ||
| 490 | ss << SRS_JOBJECT_START | 495 | ss << SRS_JOBJECT_START |
| 491 | << SRS_JFIELD_ERROR(100) << SRS_JFIELD_CONT | 496 | << SRS_JFIELD_ERROR(100) << SRS_JFIELD_CONT |
| 492 | - << SRS_JFIELD_STR("msg", "SRS demo error.") | 497 | + << SRS_JFIELD_STR("msg", "SRS demo error.") << SRS_JFIELD_CONT |
| 498 | + << SRS_JFIELD_STR("path", r->path()) | ||
| 493 | << SRS_JOBJECT_END; | 499 | << SRS_JOBJECT_END; |
| 494 | 500 | ||
| 495 | return srs_http_response_json(w, ss.str()); | 501 | return srs_http_response_json(w, ss.str()); |
| @@ -800,17 +800,27 @@ int SrsServer::http_handle() | @@ -800,17 +800,27 @@ int SrsServer::http_handle() | ||
| 800 | if ((ret = http_api_mux->handle("/api/v1/authors", new SrsGoApiAuthors())) != ERROR_SUCCESS) { | 800 | if ((ret = http_api_mux->handle("/api/v1/authors", new SrsGoApiAuthors())) != ERROR_SUCCESS) { |
| 801 | return ret; | 801 | return ret; |
| 802 | } | 802 | } |
| 803 | - if ((ret = http_api_mux->handle("/api/v1/requests", new SrsGoApiRequests())) != ERROR_SUCCESS) { | ||
| 804 | - return ret; | ||
| 805 | - } | ||
| 806 | if ((ret = http_api_mux->handle("/api/v1/vhosts", new SrsGoApiVhosts())) != ERROR_SUCCESS) { | 803 | if ((ret = http_api_mux->handle("/api/v1/vhosts", new SrsGoApiVhosts())) != ERROR_SUCCESS) { |
| 807 | return ret; | 804 | return ret; |
| 808 | } | 805 | } |
| 809 | if ((ret = http_api_mux->handle("/api/v1/streams", new SrsGoApiStreams())) != ERROR_SUCCESS) { | 806 | if ((ret = http_api_mux->handle("/api/v1/streams", new SrsGoApiStreams())) != ERROR_SUCCESS) { |
| 810 | return ret; | 807 | return ret; |
| 811 | } | 808 | } |
| 812 | - // for error test which always response error code 100. | ||
| 813 | - if ((ret = http_api_mux->handle("/api/v1/errors", new SrsGoApiError())) != ERROR_SUCCESS) { | 809 | + |
| 810 | + // test the request info. | ||
| 811 | + if ((ret = http_api_mux->handle("/api/v1/test/requests", new SrsGoApiRequests())) != ERROR_SUCCESS) { | ||
| 812 | + return ret; | ||
| 813 | + } | ||
| 814 | + // test the error code response. | ||
| 815 | + if ((ret = http_api_mux->handle("/api/v1/test/errors", new SrsGoApiError())) != ERROR_SUCCESS) { | ||
| 816 | + return ret; | ||
| 817 | + } | ||
| 818 | + // test the redirect mechenism. | ||
| 819 | + if ((ret = http_api_mux->handle("/api/v1/test/redirects", new SrsHttpRedirectHandler("/api/v1/test/errors", SRS_CONSTS_HTTP_MovedPermanently))) != ERROR_SUCCESS) { | ||
| 820 | + return ret; | ||
| 821 | + } | ||
| 822 | + // test the http vhost. | ||
| 823 | + if ((ret = http_api_mux->handle("error.srs.com/api/v1/test/errors", new SrsGoApiError())) != ERROR_SUCCESS) { | ||
| 814 | return ret; | 824 | return ret; |
| 815 | } | 825 | } |
| 816 | 826 |
-
请 注册 或 登录 后发表评论