separate http_env_request; add getQuer(), getPost(), getFiles()
[m6w6/ext-http] / php_http_request_method.c
index b482d03ec89ffa0f966c2ae2f2b72f67988aa4f0..118721f550ce5e55858f07aefa4817c4c5a157e0 100644 (file)
@@ -6,15 +6,11 @@
     | modification, are permitted provided that the conditions mentioned |
     | in the accompanying LICENSE file are met.                          |
     +--------------------------------------------------------------------+
-    | Copyright (c) 2004-2010, Michael Wallner <mike@php.net>            |
+    | Copyright (c) 2004-2011, Michael Wallner <mike@php.net>            |
     +--------------------------------------------------------------------+
 */
 
-/* $Id: http_request_method_api.c 292841 2009-12-31 08:48:57Z mike $ */
-
-#include "php_http.h"
-
-#include <Zend/zend_interfaces.h>
+#include "php_http_api.h"
 
 static PHP_HTTP_STRLIST(php_http_request_methods) =
        PHP_HTTP_STRLIST_ITEM("UNKNOWN")
@@ -36,7 +32,7 @@ static PHP_HTTP_STRLIST(php_http_request_methods) =
        PHP_HTTP_STRLIST_ITEM("LOCK")
        PHP_HTTP_STRLIST_ITEM("UNLOCK")
        /* WebDAV Versioning - RFC 3253 */
-       PHP_HTTP_STRLIST_ITEM("VERSION-CONTROL")
+       PHP_HTTP_STRLIST_ITEM("VERSION_CONTROL")
        PHP_HTTP_STRLIST_ITEM("REPORT")
        PHP_HTTP_STRLIST_ITEM("CHECKOUT")
        PHP_HTTP_STRLIST_ITEM("CHECKIN")
@@ -45,17 +41,17 @@ static PHP_HTTP_STRLIST(php_http_request_methods) =
        PHP_HTTP_STRLIST_ITEM("UPDATE")
        PHP_HTTP_STRLIST_ITEM("LABEL")
        PHP_HTTP_STRLIST_ITEM("MERGE")
-       PHP_HTTP_STRLIST_ITEM("BASELINE-CONTROL")
+       PHP_HTTP_STRLIST_ITEM("BASELINE_CONTROL")
        PHP_HTTP_STRLIST_ITEM("MKACTIVITY")
        /* WebDAV Access Control - RFC 3744 */
        PHP_HTTP_STRLIST_ITEM("ACL")
        PHP_HTTP_STRLIST_STOP
 ;
 
-PHP_HTTP_API const char *php_http_request_method_name(php_http_request_method_t meth)
+PHP_HTTP_API const char *php_http_request_method_name(php_http_request_method_t meth TSRMLS_DC)
 {
        if (meth > PHP_HTTP_NO_REQUEST_METHOD && meth < PHP_HTTP_MAX_REQUEST_METHOD) {
-               return php_http_strlist_find(php_http_request_methods, 1, meth);
+               return php_http_strlist_find(php_http_request_methods, 0, meth);
        } else {
                zval **val, *cmp, res;
                HashPosition pos;
@@ -127,12 +123,12 @@ zend_function_entry php_http_request_method_method_entry[] = {
 
 PHP_METHOD(HttpRequestMethod, __construct)
 {
-       with_error_handling(EH_THROW, PHP_HTTP_EX_CE(runtime)) {
+       with_error_handling(EH_THROW, php_http_exception_class_entry) {
                char *meth_str;
                int meth_len;
 
                if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &meth_str, &meth_len)) {
-                       with_error_handling(EH_THROW, PHP_HTTP_EX_CE(request_method)) {
+                       with_error_handling(EH_THROW, php_http_exception_class_entry) {
                                zval *zarg, *zret;
 
                                if (SUCCESS == zend_get_parameters(ZEND_NUM_ARGS(), 1, &zarg)) {
@@ -153,9 +149,9 @@ PHP_METHOD(HttpRequestMethod, __construct)
 PHP_METHOD(HttpRequestMethod, __toString)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               zval *retval = php_http_zsep(IS_STRING, zend_read_property(php_http_request_method_class_entry, getThis(), ZEND_STRL("name"), 0 TSRMLS_CC));
+               zval *retval = php_http_ztyp(IS_STRING, zend_read_property(php_http_request_method_class_entry, getThis(), ZEND_STRL("name"), 0 TSRMLS_CC));
 
-               RETURN_ZVAL(retval, 0, 0);
+               RETURN_ZVAL(retval, 1, 1);
        }
        RETURN_EMPTY_STRING();
 }
@@ -163,7 +159,7 @@ PHP_METHOD(HttpRequestMethod, __toString)
 PHP_METHOD(HttpRequestMethod, getId)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               zval **data, *meth = php_http_zsep(IS_STRING, zend_read_property(php_http_request_method_class_entry, getThis(), ZEND_STRL("name"), 0 TSRMLS_CC));
+               zval **data, *meth = php_http_ztyp(IS_STRING, zend_read_property(php_http_request_method_class_entry, getThis(), ZEND_STRL("name"), 0 TSRMLS_CC));
 
                if (SUCCESS == zend_hash_find(&php_http_request_method_class_entry->constants_table, Z_STRVAL_P(meth), Z_STRLEN_P(meth) + 1, (void *) &data)) {
                        zval_ptr_dtor(&meth);
@@ -195,7 +191,7 @@ PHP_METHOD(HttpRequestMethod, register)
        int meth_len;
 
        if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &meth_str, &meth_len)) {
-               RETURN_SUCCESS(zend_declare_class_constant_long(php_http_request_method_class_entry, meth_str, meth_len, zend_hash_num_elements(&php_http_request_class_entry->constants_table) TSRMLS_CC));
+               RETURN_SUCCESS(zend_declare_class_constant_long(php_http_request_method_class_entry, meth_str, meth_len, zend_hash_num_elements(&php_http_request_method_class_entry->constants_table) TSRMLS_CC));
        }
        RETURN_FALSE;
 }
@@ -204,7 +200,7 @@ PHP_MINIT_FUNCTION(http_request_method)
 {
        php_http_strlist_iterator_t std;
 
-       PHP_HTTP_REGISTER_CLASS(http\\request, Method, http_request_method, php_http_object_class_entry, 0);
+       PHP_HTTP_REGISTER_CLASS(http\\Request, Method, http_request_method, php_http_object_class_entry, 0);
 
        zend_declare_property_null(php_http_request_method_class_entry, ZEND_STRL("name"), ZEND_ACC_PROTECTED TSRMLS_CC);