From: Michael Wallner Date: Fri, 30 Dec 2005 19:15:45 +0000 (+0000) Subject: - s/uri/url/gi X-Git-Tag: RELEASE_0_21_0~7 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=e6d36989f0650bf097b6909c41cdd20a1ffcd6af;p=m6w6%2Fext-http - s/uri/url/gi --- diff --git a/http_functions.c b/http_functions.c index 444637e..6513149 100644 --- a/http_functions.c +++ b/http_functions.c @@ -636,7 +636,7 @@ PHP_FUNCTION(http_throttle) * * Redirect to the given url. * - * The supplied url will be expanded with http_build_uri(), the params array will + * The supplied url will be expanded with http_build_url(), the params array will * be treated with http_build_query() and the session identification will be appended * if session is true. * @@ -650,7 +650,7 @@ PHP_FUNCTION(http_throttle) * Please see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3 * for which redirect response code to use in which situation. * - * To be RFC compliant, "Redirecting to URI." will be displayed, + * To be RFC compliant, "Redirecting to URL." will be displayed, * if the client doesn't redirect immediatly, and the request method was * another one than HEAD. * @@ -706,14 +706,10 @@ PHP_FUNCTION(http_redirect) if (query_len) { spprintf(&LOC, 0, "Location: %s?%s", URI, query); - if (SG(request_info).request_method && strcmp(SG(request_info).request_method, "HEAD")) { - spprintf(&RED, 0, "Redirecting to %s?%s.\n", URI, query, URI, query); - } + spprintf(&RED, 0, "Redirecting to %s?%s.\n", URI, query, URI, query); } else { spprintf(&LOC, 0, "Location: %s", URI); - if (SG(request_info).request_method && strcmp(SG(request_info).request_method, "HEAD")) { - spprintf(&RED, 0, "Redirecting to %s.\n", URI, URI); - } + spprintf(&RED, 0, "Redirecting to %s.\n", URI, URI); } efree(URI); diff --git a/http_info_api.c b/http_info_api.c index b1ffcbc..0136a42 100644 --- a/http_info_api.c +++ b/http_info_api.c @@ -31,7 +31,7 @@ PHP_HTTP_API void _http_info_default_callback(void **nothing, HashTable **header { case IS_HTTP_REQUEST: add_assoc_string(&array, "Request Method", HTTP_INFO(info).request.method, 1); - add_assoc_string(&array, "Request Uri", HTTP_INFO(info).request.URI, 1); + add_assoc_string(&array, "Request Url", HTTP_INFO(info).request.url, 1); break; case IS_HTTP_RESPONSE: @@ -49,7 +49,7 @@ PHP_HTTP_API void _http_info_dtor(http_info *info) { case IS_HTTP_REQUEST: STR_SET(i->request.method, NULL); - STR_SET(i->request.URI, NULL); + STR_SET(i->request.url, NULL); break; case IS_HTTP_RESPONSE: @@ -120,10 +120,10 @@ PHP_HTTP_API STATUS _http_info_parse_ex(const char *pre_header, http_info *info, info->type = IS_HTTP_REQUEST; if (url && http > url) { HTTP_INFO(info).request.method = estrndup(pre_header, url - pre_header); - HTTP_INFO(info).request.URI = estrndup(url + 1, http - url - 2); + HTTP_INFO(info).request.url = estrndup(url + 1, http - url - 2); } else { HTTP_INFO(info).request.method = ecalloc(1,1); - HTTP_INFO(info).request.URI = ecalloc(1,1); + HTTP_INFO(info).request.url = ecalloc(1,1); } return SUCCESS; diff --git a/http_message_api.c b/http_message_api.c index 5f51701..16a2c05 100644 --- a/http_message_api.c +++ b/http_message_api.c @@ -48,7 +48,7 @@ static void _http_message_info_callback(http_message **message, HashTable **head { case IS_HTTP_REQUEST: (*message)->type = HTTP_MSG_REQUEST; - HTTP_INFO(*message).request.URI = estrdup(HTTP_INFO(info).request.URI); + HTTP_INFO(*message).request.url = estrdup(HTTP_INFO(info).request.url); HTTP_INFO(*message).request.method = estrdup(HTTP_INFO(info).request.method); break; @@ -74,7 +74,7 @@ static inline void _http_message_init_type(http_message *message, http_message_t case HTTP_MSG_REQUEST: message->http.info.request.method = NULL; - message->http.info.request.URI = NULL; + message->http.info.request.url = NULL; break; case HTTP_MSG_NONE: @@ -108,7 +108,7 @@ PHP_HTTP_API void _http_message_set_type(http_message *message, http_message_typ { case HTTP_MSG_REQUEST: STR_FREE(message->http.info.request.method); - STR_FREE(message->http.info.request.URI); + STR_FREE(message->http.info.request.url); break; case HTTP_MSG_RESPONSE: @@ -301,7 +301,7 @@ PHP_HTTP_API void _http_message_tostring(http_message *msg, char **string, size_ case HTTP_MSG_REQUEST: phpstr_appendf(&str, "%s %s HTTP/%1.1f" HTTP_CRLF, msg->http.info.request.method, - msg->http.info.request.URI, + msg->http.info.request.url, msg->http.version); break; @@ -396,7 +396,7 @@ PHP_HTTP_API void _http_message_tostruct_recursive(http_message *msg, zval *obj case HTTP_MSG_REQUEST: add_assoc_string(&strct, "requestMethod", msg->http.info.request.method, 1); - add_assoc_string(&strct, "requestUri", msg->http.info.request.URI, 1); + add_assoc_string(&strct, "requestUrl", msg->http.info.request.url, 1); break; case HTTP_MSG_NONE: @@ -480,7 +480,7 @@ PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC) /* check host header */ if (SUCCESS == zend_hash_find(&message->hdrs, "Host", sizeof("Host"), (void **) &zhost)) { char *colon = NULL; - php_url parts, *url = php_url_parse(message->http.info.request.URI); + php_url parts, *url = php_url_parse(message->http.info.request.url); memset(&parts, 0, sizeof(php_url)); @@ -496,7 +496,7 @@ PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC) php_url_free(url); efree(parts.host); } else { - uri = http_absolute_url(message->http.info.request.URI); + uri = http_absolute_url(message->http.info.request.url); } if ((request.meth = http_request_method_exists(1, 0, message->http.info.request.method))) { @@ -554,7 +554,7 @@ PHP_HTTP_API void _http_message_dtor(http_message *message) { case HTTP_MSG_REQUEST: STR_SET(message->http.info.request.method, NULL); - STR_SET(message->http.info.request.URI, NULL); + STR_SET(message->http.info.request.url, NULL); break; case HTTP_MSG_RESPONSE: diff --git a/http_message_object.c b/http_message_object.c index aa63cab..a0077bd 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -76,9 +76,9 @@ HTTP_BEGIN_ARGS(setRequestMethod, 0, 1) HTTP_ARG_VAL(request_method, 0) HTTP_END_ARGS; -HTTP_EMPTY_ARGS(getRequestUri, 0); -HTTP_BEGIN_ARGS(setRequestUri, 0, 1) - HTTP_ARG_VAL(uri, 0) +HTTP_EMPTY_ARGS(getRequestUrl, 0); +HTTP_BEGIN_ARGS(setRequestUrl, 0, 1) + HTTP_ARG_VAL(url, 0) HTTP_END_ARGS; HTTP_EMPTY_ARGS(getHttpVersion, 0); @@ -86,7 +86,7 @@ HTTP_BEGIN_ARGS(setHttpVersion, 0, 1) HTTP_ARG_VAL(http_version, 0) HTTP_END_ARGS; -HTTP_EMPTY_ARGS(getParentMessage, 1); +HTTP_EMPTY_ARGS(getParentMessage, 0); HTTP_EMPTY_ARGS(send, 0); HTTP_BEGIN_ARGS(toString, 0, 0) HTTP_ARG_VAL(include_parent, 0) @@ -122,8 +122,8 @@ zend_function_entry http_message_object_fe[] = { HTTP_MESSAGE_ME(setResponseCode, ZEND_ACC_PUBLIC) HTTP_MESSAGE_ME(getRequestMethod, ZEND_ACC_PUBLIC) HTTP_MESSAGE_ME(setRequestMethod, ZEND_ACC_PUBLIC) - HTTP_MESSAGE_ME(getRequestUri, ZEND_ACC_PUBLIC) - HTTP_MESSAGE_ME(setRequestUri, ZEND_ACC_PUBLIC) + HTTP_MESSAGE_ME(getRequestUrl, ZEND_ACC_PUBLIC) + HTTP_MESSAGE_ME(setRequestUrl, ZEND_ACC_PUBLIC) HTTP_MESSAGE_ME(getHttpVersion, ZEND_ACC_PUBLIC) HTTP_MESSAGE_ME(setHttpVersion, ZEND_ACC_PUBLIC) HTTP_MESSAGE_ME(getParentMessage, ZEND_ACC_PUBLIC) @@ -221,7 +221,7 @@ static inline void _http_message_object_declare_default_properties(TSRMLS_D) DCL_PROP(PROTECTED, long, type, HTTP_MSG_NONE); DCL_PROP(PROTECTED, string, body, ""); DCL_PROP(PROTECTED, string, requestMethod, ""); - DCL_PROP(PROTECTED, string, requestUri, ""); + DCL_PROP(PROTECTED, string, requestUrl, ""); DCL_PROP(PROTECTED, long, responseCode, 0); DCL_PROP_N(PROTECTED, httpVersion); DCL_PROP_N(PROTECTED, headers); @@ -313,10 +313,10 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type } break; - case HTTP_MSG_PROPHASH_REQUEST_URI: - case HTTP_MSG_CHILD_PROPHASH_REQUEST_URI: - if (HTTP_MSG_TYPE(REQUEST, msg) && msg->http.info.request.URI) { - RETVAL_STRING(msg->http.info.request.URI, 1); + case HTTP_MSG_PROPHASH_REQUEST_URL: + case HTTP_MSG_CHILD_PROPHASH_REQUEST_URL: + if (HTTP_MSG_TYPE(REQUEST, msg) && msg->http.info.request.url) { + RETVAL_STRING(msg->http.info.request.url, 1); } else { RETVAL_NULL(); } @@ -423,11 +423,11 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va } break; - case HTTP_MSG_PROPHASH_REQUEST_URI: - case HTTP_MSG_CHILD_PROPHASH_REQUEST_URI: + case HTTP_MSG_PROPHASH_REQUEST_URL: + case HTTP_MSG_CHILD_PROPHASH_REQUEST_URL: if (HTTP_MSG_TYPE(REQUEST, msg)) { convert_to_string(cpy); - STR_SET(msg->http.info.request.URI, estrndup(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy))); + STR_SET(msg->http.info.request.url, estrndup(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy))); } break; @@ -493,14 +493,14 @@ static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC) ASSOC_PROP(array, long, "responseCode", 0); ASSOC_STRINGL(array, "responseStatus", "", 0); ASSOC_STRING(array, "requestMethod", msg->http.info.request.method); - ASSOC_STRING(array, "requestUri", msg->http.info.request.URI); + ASSOC_STRING(array, "requestUrl", msg->http.info.request.url); break; case HTTP_MSG_RESPONSE: ASSOC_PROP(array, long, "responseCode", msg->http.info.response.code); ASSOC_STRING(array, "responseStatus", msg->http.info.response.status); ASSOC_STRINGL(array, "requestMethod", "", 0); - ASSOC_STRINGL(array, "requestUri", "", 0); + ASSOC_STRINGL(array, "requestUrl", "", 0); break; case HTTP_MSG_NONE: @@ -508,7 +508,7 @@ static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC) ASSOC_PROP(array, long, "responseCode", 0); ASSOC_STRINGL(array, "responseStatus", "", 0); ASSOC_STRINGL(array, "requestMethod", "", 0); - ASSOC_STRINGL(array, "requestUri", "", 0); + ASSOC_STRINGL(array, "requestUrl", "", 0); break; } @@ -835,35 +835,35 @@ PHP_METHOD(HttpMessage, setRequestMethod) } /* }}} */ -/* {{{ proto string HttpMessage::getRequestUri() +/* {{{ proto string HttpMessage::getRequestUrl() * - * Get the Request URI of the Message. + * Get the Request URL of the Message. * - * Returns the request uri as string on success, or FALSE if the message + * Returns the request url as string on success, or FALSE if the message * is not of type HttpMessage::TYPE_REQUEST. */ -PHP_METHOD(HttpMessage, getRequestUri) +PHP_METHOD(HttpMessage, getRequestUrl) { NO_ARGS; IF_RETVAL_USED { getObject(http_message_object, obj); HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj->message, RETURN_FALSE); - RETURN_STRING(obj->message->http.info.request.URI, 1); + RETURN_STRING(obj->message->http.info.request.url, 1); } } /* }}} */ -/* {{{ proto bool HttpMessage::setRequestUri(string URI) +/* {{{ proto bool HttpMessage::setRequestUrl(string url) * - * Set the Request URI of the HTTP Message. + * Set the Request URL of the HTTP Message. * - * Expects a string parameters containing the request uri. + * Expects a string parameters containing the request url. * * Returns TRUE on success, or FALSE if the message is not of type - * HttpMessage::TYPE_REQUEST or supplied URI was empty. + * HttpMessage::TYPE_REQUEST or supplied URL was empty. */ -PHP_METHOD(HttpMessage, setRequestUri) +PHP_METHOD(HttpMessage, setRequestUrl) { char *URI; int URIlen; @@ -874,11 +874,11 @@ PHP_METHOD(HttpMessage, setRequestUri) } 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"); + http_error(HE_WARNING, HTTP_E_INVALID_PARAM, "Cannot set HttpMessage::requestUrl to an empty string"); RETURN_FALSE; } - STR_SET(obj->message->http.info.request.URI, estrndup(URI, URIlen)); + STR_SET(obj->message->http.info.request.url, estrndup(URI, URIlen)); RETURN_TRUE; } /* }}} */ diff --git a/package2.xml b/package2.xml index c88dbfd..7bbff78 100644 --- a/package2.xml +++ b/package2.xml @@ -53,6 +53,7 @@ HttpResponse + Added HttpRequest::getRawRequestMessage and ::getRawResponseMessage + Added 'resetcookies' request option (libcurl > 7.15) +- Changed all methods and properties with "URI" in their name to "URL" - Changed HttpRequest properties to be private * Fixed a lot of memory corruptions within HttpRequest diff --git a/php_http_info_api.h b/php_http_info_api.h index 17f6a26..d30cead 100644 --- a/php_http_info_api.h +++ b/php_http_info_api.h @@ -22,7 +22,7 @@ typedef struct { char *method; - char *URI; + char *url; } http_request_info; typedef struct { diff --git a/php_http_message_object.h b/php_http_message_object.h index 3a3dfe8..8442f94 100644 --- a/php_http_message_object.h +++ b/php_http_message_object.h @@ -42,7 +42,7 @@ extern void _http_message_object_free(zend_object *object TSRMLS_DC); #define HTTP_MSG_PROPHASH_HEADERS 3199929089LU #define HTTP_MSG_PROPHASH_PARENT_MESSAGE 2105714836LU #define HTTP_MSG_PROPHASH_REQUEST_METHOD 1669022159LU -#define HTTP_MSG_PROPHASH_REQUEST_URI 3208695486LU +#define HTTP_MSG_PROPHASH_REQUEST_URL 3208695585LU #define HTTP_MSG_PROPHASH_RESPONSE_STATUS 3857097400LU #define HTTP_MSG_PROPHASH_RESPONSE_CODE 1305615119LU @@ -52,7 +52,7 @@ extern void _http_message_object_free(zend_object *object TSRMLS_DC); #define HTTP_MSG_CHILD_PROPHASH_HEADERS 3626850379LU #define HTTP_MSG_CHILD_PROPHASH_PARENT_MESSAGE 3910157662LU #define HTTP_MSG_CHILD_PROPHASH_REQUEST_METHOD 3473464985LU -#define HTTP_MSG_CHILD_PROPHASH_REQUEST_URI 3855912904LU +#define HTTP_MSG_CHILD_PROPHASH_REQUEST_URL 3855913003LU #define HTTP_MSG_CHILD_PROPHASH_RESPONSE_STATUS 3274168514LU #define HTTP_MSG_CHILD_PROPHASH_RESPONSE_CODE 1750746777LU @@ -81,8 +81,8 @@ PHP_METHOD(HttpMessage, getResponseCode); PHP_METHOD(HttpMessage, setResponseCode); PHP_METHOD(HttpMessage, getRequestMethod); PHP_METHOD(HttpMessage, setRequestMethod); -PHP_METHOD(HttpMessage, getRequestUri); -PHP_METHOD(HttpMessage, setRequestUri); +PHP_METHOD(HttpMessage, getRequestUrl); +PHP_METHOD(HttpMessage, setRequestUrl); PHP_METHOD(HttpMessage, getHttpVersion); PHP_METHOD(HttpMessage, setHttpVersion); PHP_METHOD(HttpMessage, getParentMessage); diff --git a/tests/HttpMessage_003.phpt b/tests/HttpMessage_003.phpt index 7caf206..2eab2dc 100644 --- a/tests/HttpMessage_003.phpt +++ b/tests/HttpMessage_003.phpt @@ -54,7 +54,7 @@ object(HttpMessage)#%d (%d) { string(2) "Ok" ["requestMethod:protected"]=> string(0) "" - ["requestUri:protected"]=> + ["requestUrl:protected"]=> string(0) "" ["headers:protected"]=> array(1) { diff --git a/tests/HttpRequest_006.phpt b/tests/HttpRequest_006.phpt index 5f933b7..ba8e6ed 100644 --- a/tests/HttpRequest_006.phpt +++ b/tests/HttpRequest_006.phpt @@ -32,7 +32,7 @@ object(HttpMessage)#%d (%d) { string(2) "OK" ["requestMethod:protected"]=> string(0) "" - ["requestUri:protected"]=> + ["requestUrl:protected"]=> string(0) "" ["headers:protected"]=> array(6) { @@ -71,7 +71,7 @@ object(HttpMessage)#%d (%d) { string(2) "OK" ["requestMethod:protected"]=> string(0) "" - ["requestUri:protected"]=> + ["requestUrl:protected"]=> string(0) "" ["headers:protected"]=> array(6) { @@ -110,7 +110,7 @@ object(HttpMessage)#%d (%d) { string(2) "OK" ["requestMethod:protected"]=> string(0) "" - ["requestUri:protected"]=> + ["requestUrl:protected"]=> string(0) "" ["headers:protected"]=> array(6) { diff --git a/tests/parse_message_004.phpt b/tests/parse_message_004.phpt index a684e84..653d083 100644 --- a/tests/parse_message_004.phpt +++ b/tests/parse_message_004.phpt @@ -57,7 +57,7 @@ object(stdClass)#1 (7) { float(1.1) ["requestMethod"]=> string(3) "GET" - ["requestUri"]=> + ["requestUrl"]=> string(1) "/" ["headers"]=> array(2) { @@ -95,7 +95,7 @@ object(stdClass)#1 (7) { float(1.1) ["requestMethod"]=> string(4) "HEAD" - ["requestUri"]=> + ["requestUrl"]=> string(1) "/" ["headers"]=> array(2) { diff --git a/tests/skip.inc b/tests/skip.inc index 268edf1..5665d5d 100644 --- a/tests/skip.inc +++ b/tests/skip.inc @@ -7,5 +7,6 @@ function checkmin($ver) { skipif(round($ver,1) > round((double) PHP_VERSION,1), function checkmax($ver) { skipif(round($ver,1) < round((double) PHP_VERSION,1), sprintf("need PHP <= v%0.1f",$ver)); } function checkurl($url) { skipif(!@fsockopen($url, 80), "$url not responsive"); } function checkcls($cls) { skipif(!class_exists($cls), "need class $cls"); } +function checkver($ver) { checkmin($ver); } checkext('http'); ?> diff --git a/tests/ut_HttpMessage.phpt b/tests/ut_HttpMessage.phpt index 6fc839e..9e8e6d1 100644 --- a/tests/ut_HttpMessage.phpt +++ b/tests/ut_HttpMessage.phpt @@ -128,21 +128,21 @@ class HttpMessageTest extends PHPUnit2_Framework_TestCase $this->assertEquals('POST', $this->requestMessage->getRequestMethod()); } - function test_getRequestUri() + function test_getRequestUrl() { - $this->assertFalse($this->emptyMessage->getRequestUri()); - $this->assertFalse($this->responseMessage->getRequestUri()); - $this->assertEquals('/foo', $this->requestMessage->getRequestUri()); + $this->assertFalse($this->emptyMessage->getRequestUrl()); + $this->assertFalse($this->responseMessage->getRequestUrl()); + $this->assertEquals('/foo', $this->requestMessage->getRequestUrl()); } - function test_setRequestUri() + function test_setRequestUrl() { - $this->assertFalse($this->emptyMessage->setRequestUri('/bla')); - $this->assertFalse($this->responseMessage->setRequestUri('/bla')); - $this->assertTrue($this->requestMessage->setRequestUri('/bla')); - $this->assertFalse($this->emptyMessage->getRequestUri()); - $this->assertFalse($this->responseMessage->getRequestUri()); - $this->assertEquals('/bla', $this->requestMessage->getRequestUri()); + $this->assertFalse($this->emptyMessage->setRequestUrl('/bla')); + $this->assertFalse($this->responseMessage->setRequestUrl('/bla')); + $this->assertTrue($this->requestMessage->setRequestUrl('/bla')); + $this->assertFalse($this->emptyMessage->getRequestUrl()); + $this->assertFalse($this->responseMessage->getRequestUrl()); + $this->assertEquals('/bla', $this->requestMessage->getRequestUrl()); } function test_getHttpVersion() @@ -250,17 +250,17 @@ Notice: HttpMessage::getRequestMethod(): HttpMessage is not of type HTTP_MSG_REQ Notice: HttpMessage::getRequestMethod(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d -Notice: HttpMessage::getRequestUri(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d +Notice: HttpMessage::getRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d -Notice: HttpMessage::getRequestUri(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d +Notice: HttpMessage::getRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d -Notice: HttpMessage::setRequestUri(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d +Notice: HttpMessage::setRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d -Notice: HttpMessage::setRequestUri(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d +Notice: HttpMessage::setRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d -Notice: HttpMessage::getRequestUri(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d +Notice: HttpMessage::getRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d -Notice: HttpMessage::getRequestUri(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d +Notice: HttpMessage::getRequestUrl(): HttpMessage is not of type HTTP_MSG_REQUEST in %sut_HttpMessage.php on line %d Time: 0