void gr_module_check_tcp( gr_tcp_req_t * req, bool * is_error, bool * is_full ) { gr_module_t * module = (gr_module_t *)g_ghost_rocket_global.module; gr_check_ctxt_t ctxt; ctxt.base = & req->check_ctxt; ctxt.port_info = req->parent->port_item; ctxt.sock = req->parent->fd; // 先判断HTTP http_check( req->buf, req->buf_len, & ctxt, is_error, is_full ); if ( GR_PACKAGE_ERROR != req->check_ctxt.package_type ) { return; } if ( NULL != module && NULL != module->chk_binary ) { * is_error = false; * is_full = false; module->chk_binary( req->buf, req->buf_len, & ctxt, & req->parent->buddy, is_error, is_full ); } else { * is_error = true; } }
static void ofp_http_check_test(void** state) { CHECK_ZERO_MEMORY_ALLOCATED; ofp_http_request_description_t desc; inplace_string_set(&desc.method, "PUT"); inplace_string_set(&desc.host, "example.com"); inplace_string_set(&desc.uri, "/index.html"); int result = http_check(&desc); assert_int_equal(HttpCheckIgnoredMethod, result); inplace_string_set(&desc.method, "GET"); result = http_check(&desc); assert_int_equal(HttpCheckSuccess, result); CHECK_ZERO_MEMORY_ALLOCATED; }
void http_cycle(void) { if (HTTPREQUESTS) http_check(); }