*
* 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.
*
* 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 <a>URI</a>." will be displayed,
+ * To be RFC compliant, "Redirecting to <a>URL</a>." will be displayed,
* if the client doesn't redirect immediatly, and the request method was
* another one than HEAD.
*
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 <a href=\"%s?%s\">%s?%s</a>.\n", URI, query, URI, query);
- }
+ spprintf(&RED, 0, "Redirecting to <a href=\"%s?%s\">%s?%s</a>.\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 <a href=\"%s\">%s</a>.\n", URI, URI);
- }
+ spprintf(&RED, 0, "Redirecting to <a href=\"%s\">%s</a>.\n", URI, URI);
}
efree(URI);
{
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:
{
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:
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;
{
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;
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:
{
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:
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;
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:
/* 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));
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))) {
{
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:
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);
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)
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)
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);
}
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();
}
}
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;
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:
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;
}
}
/* }}} */
-/* {{{ 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;
}
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;
}
/* }}} */
+ 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
typedef struct {
char *method;
- char *URI;
+ char *url;
} http_request_info;
typedef struct {
#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
#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
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);
string(2) "Ok"
["requestMethod:protected"]=>
string(0) ""
- ["requestUri:protected"]=>
+ ["requestUrl:protected"]=>
string(0) ""
["headers:protected"]=>
array(1) {
string(2) "OK"
["requestMethod:protected"]=>
string(0) ""
- ["requestUri:protected"]=>
+ ["requestUrl:protected"]=>
string(0) ""
["headers:protected"]=>
array(6) {
string(2) "OK"
["requestMethod:protected"]=>
string(0) ""
- ["requestUri:protected"]=>
+ ["requestUrl:protected"]=>
string(0) ""
["headers:protected"]=>
array(6) {
string(2) "OK"
["requestMethod:protected"]=>
string(0) ""
- ["requestUri:protected"]=>
+ ["requestUrl:protected"]=>
string(0) ""
["headers:protected"]=>
array(6) {
float(1.1)
["requestMethod"]=>
string(3) "GET"
- ["requestUri"]=>
+ ["requestUrl"]=>
string(1) "/"
["headers"]=>
array(2) {
float(1.1)
["requestMethod"]=>
string(4) "HEAD"
- ["requestUri"]=>
+ ["requestUrl"]=>
string(1) "/"
["headers"]=>
array(2) {
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');
?>
$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()
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