mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	Add test for http status.
This commit is contained in:
		
							parent
							
								
									6ce04051e4
								
							
						
					
					
						commit
						4758a284d7
					
				
					 2 changed files with 10 additions and 6 deletions
				
			
		| 
						 | 
					@ -99,9 +99,9 @@ string srs_generate_http_status_text(int status)
 | 
				
			||||||
// permits a body.  See RFC2616, section 4.4.
 | 
					// permits a body.  See RFC2616, section 4.4.
 | 
				
			||||||
bool srs_go_http_body_allowd(int status)
 | 
					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;
 | 
					        return false;
 | 
				
			||||||
    } else if (status == 204 || status == 304) {
 | 
					    } else if (status == SRS_CONSTS_HTTP_NoContent || status == SRS_CONSTS_HTTP_NotModified) {
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					@ -116,9 +116,7 @@ bool srs_go_http_body_allowd(int status)
 | 
				
			||||||
// returns "application/octet-stream".
 | 
					// returns "application/octet-stream".
 | 
				
			||||||
string srs_go_http_detect(char* data, int size)
 | 
					string srs_go_http_detect(char* data, int size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    // detect only when data specified.
 | 
					    // TODO: Implement the content detecting.
 | 
				
			||||||
    if (data) {
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return "application/octet-stream"; // fallback
 | 
					    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>
 | 
					#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(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_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…
	
	Add table
		Add a link
		
	
		Reference in a new issue