- fix aliases and exports
[m6w6/ext-http] / http_request_object.c
index bc7a0f854e1107fd361fd67fd7f501ca8bd14aa3..207ec6c3da02fd4923196b263cead20f22b3824b 100644 (file)
@@ -190,6 +190,13 @@ HTTP_BEGIN_ARGS(postFields, 2)
        HTTP_ARG_VAL(info, 1)
 HTTP_END_ARGS;
 
+HTTP_BEGIN_ARGS(putData, 2)
+       HTTP_ARG_VAL(url, 0)
+       HTTP_ARG_VAL(data, 0)
+       HTTP_ARG_VAL(options, 0)
+       HTTP_ARG_VAL(info, 1)
+HTTP_END_ARGS;
+
 HTTP_BEGIN_ARGS(putFile, 2)
        HTTP_ARG_VAL(url, 0)
        HTTP_ARG_VAL(file, 0)
@@ -220,6 +227,11 @@ HTTP_BEGIN_ARGS(methodExists, 1)
        HTTP_ARG_VAL(method, 0)
 HTTP_END_ARGS;
 
+HTTP_BEGIN_ARGS(encodeBody, 2)
+       HTTP_ARG_VAL(fields, 0)
+       HTTP_ARG_VAL(files, 0)
+HTTP_END_ARGS;
+
 #define OBJ_PROP_CE http_request_object_ce
 zend_class_entry *http_request_object_ce;
 zend_function_entry http_request_object_fe[] = {
@@ -291,6 +303,7 @@ zend_function_entry http_request_object_fe[] = {
        HTTP_REQUEST_ALIAS(head, http_head)
        HTTP_REQUEST_ALIAS(postData, http_post_data)
        HTTP_REQUEST_ALIAS(postFields, http_post_fields)
+       HTTP_REQUEST_ALIAS(putData, http_put_data)
        HTTP_REQUEST_ALIAS(putFile, http_put_file)
        HTTP_REQUEST_ALIAS(putStream, http_put_stream)
 
@@ -298,6 +311,8 @@ zend_function_entry http_request_object_fe[] = {
        HTTP_REQUEST_ALIAS(methodUnregister, http_request_method_unregister)
        HTTP_REQUEST_ALIAS(methodName, http_request_method_name)
        HTTP_REQUEST_ALIAS(methodExists, http_request_method_exists)
+       
+       HTTP_REQUEST_ALIAS(encodeBody, http_request_body_encode)
 
        EMPTY_FUNCTION_ENTRY
 };
@@ -633,7 +648,7 @@ STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this
                }
 
                UPD_PROP(long, responseCode, msg->http.info.response.code);
-               UPD_PROP(string, responseStatus, msg->http.info.response.status);
+               UPD_PROP(string, responseStatus, msg->http.info.response.status ? msg->http.info.response.status : "");
 
                MAKE_STD_ZVAL(resp);
                array_init(resp);
@@ -688,12 +703,14 @@ STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this
                ret = FAILURE;
        }
        
-       if (zend_hash_exists(&Z_OBJCE_P(getThis())->function_table, "onfinish", sizeof("onfinish"))) {
+       if (!EG(exception) && zend_hash_exists(&Z_OBJCE_P(getThis())->function_table, "onfinish", sizeof("onfinish"))) {
                zval *param;
                
                MAKE_STD_ZVAL(param);
                ZVAL_BOOL(param, ret == SUCCESS);
-               zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "onfinish", NULL, param);
+               with_error_handling(EH_NORMAL, NULL) {
+                       zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "onfinish", NULL, param);
+               } end_error_handling();
                zval_ptr_dtor(&param);
        }