X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_message_object.c;h=d588192e2fc0e8e523eba35c1297f32f6a2090ff;hp=759c75a94f8cfee7ea7b06487d766f1a62fd0d6a;hb=39feb7a7e30bb4b393a6f76aa2f35d4e9275523e;hpb=2334ad58dd0d288f1ef49ab3d449376763df4fba diff --git a/http_message_object.c b/http_message_object.c index 759c75a..d588192 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -702,12 +702,7 @@ PHP_METHOD(HttpMessage, getResponseCode) IF_RETVAL_USED { getObject(http_message_object, obj); - - if (!HTTP_MSG_TYPE(RESPONSE, obj->message)) { - http_error(HE_NOTICE, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_RESPONSE"); - RETURN_FALSE; - } - + HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj->message, RETURN_FALSE); RETURN_LONG(obj->message->http.info.response.code); } } @@ -727,10 +722,7 @@ PHP_METHOD(HttpMessage, setResponseCode) long code; getObject(http_message_object, obj); - if (!HTTP_MSG_TYPE(RESPONSE, obj->message)) { - http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_RESPONSE"); - RETURN_FALSE; - } + HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj->message, RETURN_FALSE); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &code)) { RETURN_FALSE; @@ -758,12 +750,7 @@ PHP_METHOD(HttpMessage, getRequestMethod) IF_RETVAL_USED { getObject(http_message_object, obj); - - if (!HTTP_MSG_TYPE(REQUEST, obj->message)) { - http_error(HE_NOTICE, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_REQUEST"); - RETURN_FALSE; - } - + HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj->message, RETURN_FALSE); RETURN_STRING(obj->message->http.info.request.method, 1); } } @@ -784,10 +771,7 @@ PHP_METHOD(HttpMessage, setRequestMethod) int method_len; getObject(http_message_object, obj); - if (!HTTP_MSG_TYPE(REQUEST, obj->message)) { - http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_REQUEST"); - RETURN_FALSE; - } + HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj->message, RETURN_FALSE); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &method, &method_len)) { RETURN_FALSE; @@ -819,12 +803,7 @@ PHP_METHOD(HttpMessage, getRequestUri) IF_RETVAL_USED { getObject(http_message_object, obj); - - if (!HTTP_MSG_TYPE(REQUEST, obj->message)) { - http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_REQUEST"); - RETURN_FALSE; - } - + HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj->message, RETURN_FALSE); RETURN_STRING(obj->message->http.info.request.URI, 1); } } @@ -845,13 +824,10 @@ PHP_METHOD(HttpMessage, setRequestUri) int URIlen; getObject(http_message_object, obj); - if (!HTTP_MSG_TYPE(REQUEST, obj->message)) { - http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_REQUEST"); - RETURN_FALSE; - } if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &URI, &URIlen)) { RETURN_FALSE; } + HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj->message, RETURN_FALSE); if (URIlen < 1) { http_error(HE_WARNING, HTTP_E_INVALID_PARAM, "Cannot set HttpMessage::requestUri to an empty string"); RETURN_FALSE;