-/* {{{ proto private HttpRequest::debugWrapper(long type, string message)
- */
-PHP_METHOD(HttpRequest, debugWrapper)
-{
- static int curl_ignores_body = 0;
- getObject(http_request_object, obj);
- zval *type, *message, *dbg_user_cb = GET_PROP(obj, dbg_user_cb);
-
- if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &type, &message)) {
- RETURN_NULL();
- }
-
- if (Z_TYPE_P(type) != IS_LONG) {
- convert_to_long_ex(&type);
- }
- if (Z_TYPE_P(message) != IS_STRING) {
- convert_to_string_ex(&message);
- }
-
- switch (Z_LVAL_P(type))
- {
- case CURLINFO_DATA_IN:
- /* fetch ignored body */
- if (curl_ignores_body && Z_LVAL_P(type) == CURLINFO_DATA_IN) {
- phpstr_append(&obj->response, Z_STRVAL_P(message), Z_STRLEN_P(message));
- }
- break;
-
- case CURLINFO_TEXT:
- /* check if following incoming data would be ignored */
- curl_ignores_body = !strcmp(Z_STRVAL_P(message), "Ignoring the response-body\n");
- break;
-
- case CURLINFO_HEADER_OUT:
- case CURLINFO_DATA_OUT:
- /* fetch outgoing request message */
- phpstr_append(&obj->request, Z_STRVAL_P(message), Z_STRLEN_P(message));
- break;
- }
-
- /* call user debug callback */
- if (Z_TYPE_P(dbg_user_cb) != IS_NULL) {
- zval *args[2], cb_ret;
-
- args[0] = type;
- args[1] = message;
- call_user_function(EG(function_table), NULL, dbg_user_cb, &cb_ret, 2, args TSRMLS_CC);
- }
-
- RETURN_NULL();
-}
-/* }}} */
-