Add test for http status.

pull/1568/head
winlin 5 years ago
parent 6ce04051e4
commit 4758a284d7

@ -99,9 +99,9 @@ string srs_generate_http_status_text(int status)
// permits a body. See RFC2616, section 4.4.
bool srs_go_http_body_allowd(int status)
{
if (status >= 100 && status <= 199) {
if (status >= SRS_CONSTS_HTTP_Continue && status < SRS_CONSTS_HTTP_OK) {
return false;
} else if (status == 204 || status == 304) {
} else if (status == SRS_CONSTS_HTTP_NoContent || status == SRS_CONSTS_HTTP_NotModified) {
return false;
}
@ -116,9 +116,7 @@ bool srs_go_http_body_allowd(int status)
// returns "application/octet-stream".
string srs_go_http_detect(char* data, int size)
{
// detect only when data specified.
if (data) {
}
// TODO: Implement the content detecting.
return "application/octet-stream"; // fallback
}

@ -24,8 +24,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_http_stack.hpp>
VOID TEST(ProtoStackTest, StatusCode2Text)
VOID TEST(ProtocolHTTPTest, StatusCode2Text)
{
EXPECT_STREQ(SRS_CONSTS_HTTP_OK_str, srs_generate_http_status_text(SRS_CONSTS_HTTP_OK).c_str());
EXPECT_STREQ("Status Unknown", srs_generate_http_status_text(999).c_str());
EXPECT_FALSE(srs_go_http_body_allowd(SRS_CONSTS_HTTP_Continue));
EXPECT_FALSE(srs_go_http_body_allowd(SRS_CONSTS_HTTP_OK-1));
EXPECT_FALSE(srs_go_http_body_allowd(SRS_CONSTS_HTTP_NoContent));
EXPECT_FALSE(srs_go_http_body_allowd(SRS_CONSTS_HTTP_NotModified));
EXPECT_TRUE(srs_go_http_body_allowd(SRS_CONSTS_HTTP_OK));
}

Loading…
Cancel
Save