2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2006, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
15 #define HTTP_WANT_SAPI
16 #define HTTP_WANT_CURL
21 #include "zend_interfaces.h"
22 #include "ext/standard/url.h"
24 #include "php_http_api.h"
25 #include "php_http_send_api.h"
26 #include "php_http_url_api.h"
27 #include "php_http_message_api.h"
28 #include "php_http_message_object.h"
29 #include "php_http_exception_object.h"
30 #include "php_http_response_object.h"
31 #include "php_http_request_method_api.h"
32 #include "php_http_request_api.h"
33 #include "php_http_request_object.h"
37 /* SPL doesn't install its headers */
38 extern PHPAPI zend_class_entry
*spl_ce_Countable
;
42 #define HTTP_BEGIN_ARGS(method, ret_ref, req_args) HTTP_BEGIN_ARGS_EX(HttpMessage, method, ret_ref, req_args)
43 #define HTTP_EMPTY_ARGS(method, ret_ref) HTTP_EMPTY_ARGS_EX(HttpMessage, method, ret_ref)
44 #define HTTP_MESSAGE_ME(method, visibility) PHP_ME(HttpMessage, method, HTTP_ARGS(HttpMessage, method), visibility)
46 HTTP_BEGIN_ARGS(__construct
, 0, 0)
47 HTTP_ARG_VAL(message
, 0)
50 HTTP_BEGIN_ARGS(fromString
, 1, 1)
51 HTTP_ARG_VAL(message
, 0)
54 HTTP_EMPTY_ARGS(getBody
, 0);
55 HTTP_BEGIN_ARGS(setBody
, 0, 1)
59 HTTP_EMPTY_ARGS(getHeaders
, 0);
60 HTTP_BEGIN_ARGS(setHeaders
, 0, 1)
61 HTTP_ARG_VAL(headers
, 0)
64 HTTP_BEGIN_ARGS(addHeaders
, 0, 1)
65 HTTP_ARG_VAL(headers
, 0)
66 HTTP_ARG_VAL(append
, 0)
69 HTTP_EMPTY_ARGS(getType
, 0);
70 HTTP_BEGIN_ARGS(setType
, 0, 1)
74 HTTP_EMPTY_ARGS(getResponseCode
, 0);
75 HTTP_BEGIN_ARGS(setResponseCode
, 0, 1)
76 HTTP_ARG_VAL(response_code
, 0)
79 HTTP_EMPTY_ARGS(getResponseStatus
, 0);
80 HTTP_BEGIN_ARGS(setResponseStatus
, 0, 1)
81 HTTP_ARG_VAL(response_status
, 0)
84 HTTP_EMPTY_ARGS(getRequestMethod
, 0);
85 HTTP_BEGIN_ARGS(setRequestMethod
, 0, 1)
86 HTTP_ARG_VAL(request_method
, 0)
89 HTTP_EMPTY_ARGS(getRequestUrl
, 0);
90 HTTP_BEGIN_ARGS(setRequestUrl
, 0, 1)
94 HTTP_EMPTY_ARGS(getHttpVersion
, 0);
95 HTTP_BEGIN_ARGS(setHttpVersion
, 0, 1)
96 HTTP_ARG_VAL(http_version
, 0)
99 HTTP_EMPTY_ARGS(getParentMessage
, 0);
100 HTTP_EMPTY_ARGS(send
, 0);
101 HTTP_BEGIN_ARGS(toString
, 0, 0)
102 HTTP_ARG_VAL(include_parent
, 0)
105 HTTP_EMPTY_ARGS(toMessageTypeObject
, 0);
107 HTTP_EMPTY_ARGS(count
, 0);
109 HTTP_EMPTY_ARGS(serialize
, 0);
110 HTTP_BEGIN_ARGS(unserialize
, 0, 1)
111 HTTP_ARG_VAL(serialized
, 0)
114 HTTP_EMPTY_ARGS(rewind
, 0);
115 HTTP_EMPTY_ARGS(valid
, 0);
116 HTTP_EMPTY_ARGS(key
, 0);
117 HTTP_EMPTY_ARGS(current
, 0);
118 HTTP_EMPTY_ARGS(next
, 0);
120 HTTP_EMPTY_ARGS(detach
, 0);
121 HTTP_BEGIN_ARGS(prepend
, 0, 1)
122 HTTP_ARG_OBJ(HttpMessage
, message
, 0)
125 #define http_message_object_declare_default_properties() _http_message_object_declare_default_properties(TSRMLS_C)
126 static inline void _http_message_object_declare_default_properties(TSRMLS_D
);
127 #define http_message_object_read_prop _http_message_object_read_prop
128 static zval
*_http_message_object_read_prop(zval
*object
, zval
*member
, int type TSRMLS_DC
);
129 #define http_message_object_write_prop _http_message_object_write_prop
130 static void _http_message_object_write_prop(zval
*object
, zval
*member
, zval
*value TSRMLS_DC
);
131 #define http_message_object_get_props _http_message_object_get_props
132 static HashTable
*_http_message_object_get_props(zval
*object TSRMLS_DC
);
134 zend_class_entry
*http_message_object_ce
;
135 zend_function_entry http_message_object_fe
[] = {
136 HTTP_MESSAGE_ME(__construct
, ZEND_ACC_PUBLIC
|ZEND_ACC_CTOR
)
137 HTTP_MESSAGE_ME(getBody
, ZEND_ACC_PUBLIC
)
138 HTTP_MESSAGE_ME(setBody
, ZEND_ACC_PUBLIC
)
139 HTTP_MESSAGE_ME(getHeaders
, ZEND_ACC_PUBLIC
)
140 HTTP_MESSAGE_ME(setHeaders
, ZEND_ACC_PUBLIC
)
141 HTTP_MESSAGE_ME(addHeaders
, ZEND_ACC_PUBLIC
)
142 HTTP_MESSAGE_ME(getType
, ZEND_ACC_PUBLIC
)
143 HTTP_MESSAGE_ME(setType
, ZEND_ACC_PUBLIC
)
144 HTTP_MESSAGE_ME(getResponseCode
, ZEND_ACC_PUBLIC
)
145 HTTP_MESSAGE_ME(setResponseCode
, ZEND_ACC_PUBLIC
)
146 HTTP_MESSAGE_ME(getResponseStatus
, ZEND_ACC_PUBLIC
)
147 HTTP_MESSAGE_ME(setResponseStatus
, ZEND_ACC_PUBLIC
)
148 HTTP_MESSAGE_ME(getRequestMethod
, ZEND_ACC_PUBLIC
)
149 HTTP_MESSAGE_ME(setRequestMethod
, ZEND_ACC_PUBLIC
)
150 HTTP_MESSAGE_ME(getRequestUrl
, ZEND_ACC_PUBLIC
)
151 HTTP_MESSAGE_ME(setRequestUrl
, ZEND_ACC_PUBLIC
)
152 HTTP_MESSAGE_ME(getHttpVersion
, ZEND_ACC_PUBLIC
)
153 HTTP_MESSAGE_ME(setHttpVersion
, ZEND_ACC_PUBLIC
)
154 HTTP_MESSAGE_ME(getParentMessage
, ZEND_ACC_PUBLIC
)
155 HTTP_MESSAGE_ME(send
, ZEND_ACC_PUBLIC
)
156 HTTP_MESSAGE_ME(toString
, ZEND_ACC_PUBLIC
)
157 HTTP_MESSAGE_ME(toMessageTypeObject
, ZEND_ACC_PUBLIC
)
159 /* implements Countable */
160 HTTP_MESSAGE_ME(count
, ZEND_ACC_PUBLIC
)
162 /* implements Serializable */
163 HTTP_MESSAGE_ME(serialize
, ZEND_ACC_PUBLIC
)
164 HTTP_MESSAGE_ME(unserialize
, ZEND_ACC_PUBLIC
)
166 /* implements Iterator */
167 HTTP_MESSAGE_ME(rewind
, ZEND_ACC_PUBLIC
)
168 HTTP_MESSAGE_ME(valid
, ZEND_ACC_PUBLIC
)
169 HTTP_MESSAGE_ME(current
, ZEND_ACC_PUBLIC
)
170 HTTP_MESSAGE_ME(key
, ZEND_ACC_PUBLIC
)
171 HTTP_MESSAGE_ME(next
, ZEND_ACC_PUBLIC
)
173 ZEND_MALIAS(HttpMessage
, __toString
, toString
, HTTP_ARGS(HttpMessage
, toString
), ZEND_ACC_PUBLIC
)
175 HTTP_MESSAGE_ME(fromString
, ZEND_ACC_PUBLIC
|ZEND_ACC_STATIC
)
177 HTTP_MESSAGE_ME(detach
, ZEND_ACC_PUBLIC
)
178 HTTP_MESSAGE_ME(prepend
, ZEND_ACC_PUBLIC
)
182 static zend_object_handlers http_message_object_handlers
;
184 PHP_MINIT_FUNCTION(http_message_object
)
186 HTTP_REGISTER_CLASS_EX(HttpMessage
, http_message_object
, NULL
, 0);
189 zend_class_implements(http_message_object_ce TSRMLS_CC
, 3, spl_ce_Countable
, zend_ce_serializable
, zend_ce_iterator
);
191 zend_class_implements(http_message_object_ce TSRMLS_CC
, 2, zend_ce_serializable
, zend_ce_iterator
);
194 zend_class_implements(http_message_object_ce TSRMLS_CC
, 1, zend_ce_iterator
);
197 HTTP_LONG_CONSTANT("HTTP_MSG_NONE", HTTP_MSG_NONE
);
198 HTTP_LONG_CONSTANT("HTTP_MSG_REQUEST", HTTP_MSG_REQUEST
);
199 HTTP_LONG_CONSTANT("HTTP_MSG_RESPONSE", HTTP_MSG_RESPONSE
);
201 http_message_object_handlers
.clone_obj
= _http_message_object_clone_obj
;
202 http_message_object_handlers
.read_property
= http_message_object_read_prop
;
203 http_message_object_handlers
.write_property
= http_message_object_write_prop
;
204 http_message_object_handlers
.get_properties
= http_message_object_get_props
;
205 http_message_object_handlers
.get_property_ptr_ptr
= NULL
;
210 zend_object_value
_http_message_object_new(zend_class_entry
*ce TSRMLS_DC
)
212 return http_message_object_new_ex(ce
, NULL
, NULL
);
215 zend_object_value
_http_message_object_new_ex(zend_class_entry
*ce
, http_message
*msg
, http_message_object
**ptr TSRMLS_DC
)
217 zend_object_value ov
;
218 http_message_object
*o
;
220 o
= ecalloc(1, sizeof(http_message_object
));
230 o
->parent
= http_message_object_new_ex(ce
, msg
->parent
, NULL
);
234 ALLOC_HASHTABLE(OBJ_PROP(o
));
235 zend_hash_init(OBJ_PROP(o
), 0, NULL
, ZVAL_PTR_DTOR
, 0);
237 ov
.handle
= putObject(http_message_object
, o
);
238 ov
.handlers
= &http_message_object_handlers
;
243 zend_object_value
_http_message_object_clone_obj(zval
*this_ptr TSRMLS_DC
)
245 getObject(http_message_object
, obj
);
246 return http_message_object_new_ex(Z_OBJCE_P(this_ptr
), http_message_dup(obj
->message
), NULL
);
249 static inline void _http_message_object_declare_default_properties(TSRMLS_D
)
251 zend_class_entry
*ce
= http_message_object_ce
;
254 DCL_CONST(long, "TYPE_NONE", HTTP_MSG_NONE
);
255 DCL_CONST(long, "TYPE_REQUEST", HTTP_MSG_REQUEST
);
256 DCL_CONST(long, "TYPE_RESPONSE", HTTP_MSG_RESPONSE
);
259 DCL_PROP(PROTECTED
, long, type
, HTTP_MSG_NONE
);
260 DCL_PROP(PROTECTED
, string
, body
, "");
261 DCL_PROP(PROTECTED
, string
, requestMethod
, "");
262 DCL_PROP(PROTECTED
, string
, requestUrl
, "");
263 DCL_PROP(PROTECTED
, string
, responseStatus
, "");
264 DCL_PROP(PROTECTED
, long, responseCode
, 0);
265 DCL_PROP_N(PROTECTED
, httpVersion
);
266 DCL_PROP_N(PROTECTED
, headers
);
267 DCL_PROP_N(PROTECTED
, parentMessage
);
270 void _http_message_object_free(zend_object
*object TSRMLS_DC
)
272 http_message_object
*o
= (http_message_object
*) object
;
275 zend_hash_destroy(OBJ_PROP(o
));
276 FREE_HASHTABLE(OBJ_PROP(o
));
279 http_message_dtor(o
->message
);
282 if (o
->parent
.handle
) {
287 p
.value
.obj
= o
->parent
;
288 zend_objects_store_del_ref(&p TSRMLS_CC
);
293 static zval
*_http_message_object_read_prop(zval
*object
, zval
*member
, int type TSRMLS_DC
)
295 getObjectEx(http_message_object
, obj
, object
);
296 http_message
*msg
= obj
->message
;
299 ulong h
= zend_get_hash_value(Z_STRVAL_P(member
), Z_STRLEN_P(member
)+1);
301 zend_property_info
*pinfo
= zend_get_property_info(obj
->zo
.ce
, member
, 1 TSRMLS_CC
);
303 if (!pinfo
|| ACC_PROP_PUBLIC(pinfo
->flags
)) {
304 return zend_get_std_object_handlers()->read_property(object
, member
, type TSRMLS_CC
);
308 if (type
== BP_VAR_W
) {
309 zend_error(E_ERROR
, "Cannot access HttpMessage properties by reference or array key/index");
313 ALLOC_ZVAL(return_value
);
314 return_value
->refcount
= 0;
315 return_value
->is_ref
= 0;
323 case HTTP_MSG_PROPHASH_TYPE
:
324 case HTTP_MSG_CHILD_PROPHASH_TYPE
:
325 RETVAL_LONG(msg
->type
);
328 case HTTP_MSG_PROPHASH_HTTP_VERSION
:
329 case HTTP_MSG_CHILD_PROPHASH_HTTP_VERSION
:
330 RETVAL_DOUBLE(msg
->http
.version
);
333 case HTTP_MSG_PROPHASH_BODY
:
334 case HTTP_MSG_CHILD_PROPHASH_BODY
:
335 phpstr_fix(PHPSTR(msg
));
336 RETVAL_PHPSTR(PHPSTR(msg
), 0, 1);
339 case HTTP_MSG_PROPHASH_HEADERS
:
340 case HTTP_MSG_CHILD_PROPHASH_HEADERS
:
341 array_init(return_value
);
342 zend_hash_copy(Z_ARRVAL_P(return_value
), &msg
->hdrs
, (copy_ctor_func_t
) zval_add_ref
, NULL
, sizeof(zval
*));
345 case HTTP_MSG_PROPHASH_PARENT_MESSAGE
:
346 case HTTP_MSG_CHILD_PROPHASH_PARENT_MESSAGE
:
348 RETVAL_OBJVAL(obj
->parent
, 1);
354 case HTTP_MSG_PROPHASH_REQUEST_METHOD
:
355 case HTTP_MSG_CHILD_PROPHASH_REQUEST_METHOD
:
356 if (HTTP_MSG_TYPE(REQUEST
, msg
) && msg
->http
.info
.request
.method
) {
357 RETVAL_STRING(msg
->http
.info
.request
.method
, 1);
363 case HTTP_MSG_PROPHASH_REQUEST_URL
:
364 case HTTP_MSG_CHILD_PROPHASH_REQUEST_URL
:
365 if (HTTP_MSG_TYPE(REQUEST
, msg
) && msg
->http
.info
.request
.url
) {
366 RETVAL_STRING(msg
->http
.info
.request
.url
, 1);
372 case HTTP_MSG_PROPHASH_RESPONSE_CODE
:
373 case HTTP_MSG_CHILD_PROPHASH_RESPONSE_CODE
:
374 if (HTTP_MSG_TYPE(RESPONSE
, msg
)) {
375 RETVAL_LONG(msg
->http
.info
.response
.code
);
381 case HTTP_MSG_PROPHASH_RESPONSE_STATUS
:
382 case HTTP_MSG_CHILD_PROPHASH_RESPONSE_STATUS
:
383 if (HTTP_MSG_TYPE(RESPONSE
, msg
) && msg
->http
.info
.response
.status
) {
384 RETVAL_STRING(msg
->http
.info
.response
.status
, 1);
392 return zend_get_std_object_handlers()->read_property(object
, member
, type TSRMLS_CC
);
402 static void _http_message_object_write_prop(zval
*object
, zval
*member
, zval
*value TSRMLS_DC
)
404 getObjectEx(http_message_object
, obj
, object
);
405 http_message
*msg
= obj
->message
;
408 ulong h
= zend_get_hash_value(Z_STRVAL_P(member
), Z_STRLEN_P(member
) + 1);
410 zend_property_info
*pinfo
= zend_get_property_info(obj
->zo
.ce
, member
, 1 TSRMLS_CC
);
412 if (!pinfo
|| ACC_PROP_PUBLIC(pinfo
->flags
)) {
413 zend_get_std_object_handlers()->write_property(object
, member
, value TSRMLS_CC
);
418 cpy
= zval_copy(Z_TYPE_P(value
), value
);
426 case HTTP_MSG_PROPHASH_TYPE
:
427 case HTTP_MSG_CHILD_PROPHASH_TYPE
:
428 convert_to_long(cpy
);
429 http_message_set_type(msg
, Z_LVAL_P(cpy
));
432 case HTTP_MSG_PROPHASH_HTTP_VERSION
:
433 case HTTP_MSG_CHILD_PROPHASH_HTTP_VERSION
:
434 convert_to_double(cpy
);
435 msg
->http
.version
= Z_DVAL_P(cpy
);
438 case HTTP_MSG_PROPHASH_BODY
:
439 case HTTP_MSG_CHILD_PROPHASH_BODY
:
440 convert_to_string(cpy
);
441 phpstr_dtor(PHPSTR(msg
));
442 phpstr_from_string_ex(PHPSTR(msg
), Z_STRVAL_P(cpy
), Z_STRLEN_P(cpy
));
445 case HTTP_MSG_PROPHASH_HEADERS
:
446 case HTTP_MSG_CHILD_PROPHASH_HEADERS
:
447 convert_to_array(cpy
);
448 zend_hash_clean(&msg
->hdrs
);
449 zend_hash_copy(&msg
->hdrs
, Z_ARRVAL_P(cpy
), (copy_ctor_func_t
) zval_add_ref
, NULL
, sizeof(zval
*));
452 case HTTP_MSG_PROPHASH_PARENT_MESSAGE
:
453 case HTTP_MSG_CHILD_PROPHASH_PARENT_MESSAGE
:
454 if (Z_TYPE_P(value
) == IS_OBJECT
&& instanceof_function(Z_OBJCE_P(value
), http_message_object_ce TSRMLS_CC
)) {
457 tmp
.value
.obj
= obj
->parent
;
460 Z_OBJ_ADDREF_P(value
);
461 obj
->parent
= value
->value
.obj
;
465 case HTTP_MSG_PROPHASH_REQUEST_METHOD
:
466 case HTTP_MSG_CHILD_PROPHASH_REQUEST_METHOD
:
467 if (HTTP_MSG_TYPE(REQUEST
, msg
)) {
468 convert_to_string(cpy
);
469 STR_SET(msg
->http
.info
.request
.method
, estrndup(Z_STRVAL_P(cpy
), Z_STRLEN_P(cpy
)));
473 case HTTP_MSG_PROPHASH_REQUEST_URL
:
474 case HTTP_MSG_CHILD_PROPHASH_REQUEST_URL
:
475 if (HTTP_MSG_TYPE(REQUEST
, msg
)) {
476 convert_to_string(cpy
);
477 STR_SET(msg
->http
.info
.request
.url
, estrndup(Z_STRVAL_P(cpy
), Z_STRLEN_P(cpy
)));
481 case HTTP_MSG_PROPHASH_RESPONSE_CODE
:
482 case HTTP_MSG_CHILD_PROPHASH_RESPONSE_CODE
:
483 if (HTTP_MSG_TYPE(RESPONSE
, msg
)) {
484 convert_to_long(cpy
);
485 msg
->http
.info
.response
.code
= Z_LVAL_P(cpy
);
489 case HTTP_MSG_PROPHASH_RESPONSE_STATUS
:
490 case HTTP_MSG_CHILD_PROPHASH_RESPONSE_STATUS
:
491 if (HTTP_MSG_TYPE(RESPONSE
, msg
)) {
492 convert_to_string(cpy
);
493 STR_SET(msg
->http
.info
.response
.status
, estrndup(Z_STRVAL_P(cpy
), Z_STRLEN_P(cpy
)));
499 zend_get_std_object_handlers()->write_property(object
, member
, value TSRMLS_CC
);
506 static HashTable
*_http_message_object_get_props(zval
*object TSRMLS_DC
)
509 getObjectEx(http_message_object
, obj
, object
);
510 http_message
*msg
= obj
->message
;
511 HashTable
*props
= OBJ_PROP(obj
);
514 INIT_ZARR(array
, props
);
516 #define ASSOC_PROP(array, ptype, name, val) \
520 zend_mangle_property_name(&m_prop_name, &m_prop_len, "*", 1, name, lenof(name), 0); \
521 add_assoc_ ##ptype## _ex(&array, m_prop_name, sizeof(name)+3, val); \
522 efree(m_prop_name); \
524 #define ASSOC_STRING(array, name, val) ASSOC_STRINGL(array, name, val, strlen(val))
525 #define ASSOC_STRINGL(array, name, val, len) \
529 zend_mangle_property_name(&m_prop_name, &m_prop_len, "*", 1, name, lenof(name), 0); \
530 add_assoc_stringl_ex(&array, m_prop_name, sizeof(name)+3, val, len, 1); \
531 efree(m_prop_name); \
534 ASSOC_PROP(array
, long, "type", msg
->type
);
535 ASSOC_PROP(array
, double, "httpVersion", msg
->http
.version
);
539 case HTTP_MSG_REQUEST
:
540 ASSOC_PROP(array
, long, "responseCode", 0);
541 ASSOC_STRINGL(array
, "responseStatus", "", 0);
542 ASSOC_STRING(array
, "requestMethod", msg
->http
.info
.request
.method
);
543 ASSOC_STRING(array
, "requestUrl", msg
->http
.info
.request
.url
);
546 case HTTP_MSG_RESPONSE
:
547 ASSOC_PROP(array
, long, "responseCode", msg
->http
.info
.response
.code
);
548 ASSOC_STRING(array
, "responseStatus", msg
->http
.info
.response
.status
);
549 ASSOC_STRINGL(array
, "requestMethod", "", 0);
550 ASSOC_STRINGL(array
, "requestUrl", "", 0);
555 ASSOC_PROP(array
, long, "responseCode", 0);
556 ASSOC_STRINGL(array
, "responseStatus", "", 0);
557 ASSOC_STRINGL(array
, "requestMethod", "", 0);
558 ASSOC_STRINGL(array
, "requestUrl", "", 0);
562 MAKE_STD_ZVAL(headers
);
564 zend_hash_copy(Z_ARRVAL_P(headers
), &msg
->hdrs
, (copy_ctor_func_t
) zval_add_ref
, NULL
, sizeof(zval
*));
565 ASSOC_PROP(array
, zval
, "headers", headers
);
566 ASSOC_STRINGL(array
, "body", PHPSTR_VAL(msg
), PHPSTR_LEN(msg
));
568 return OBJ_PROP(obj
);
571 /* ### USERLAND ### */
573 /* {{{ proto void HttpMessage::__construct([string message])
575 * Instantiate a new HttpMessage object.
577 * Accepts an optional string parameter containing a single or several
578 * consecutive HTTP messages. The constructed object will actually
579 * represent the *last* message of the passed string. If there were
580 * prior messages, those can be accessed by HttpMessage::getParentMessage().
582 * Throws HttpMalformedHeaderException.
584 PHP_METHOD(HttpMessage
, __construct
)
587 char *message
= NULL
;
589 getObject(http_message_object
, obj
);
592 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|s", &message
, &length
) && message
&& length
) {
593 http_message
*msg
= obj
->message
;
595 http_message_dtor(msg
);
596 if ((obj
->message
= http_message_parse_ex(msg
, message
, length
))) {
597 if (obj
->message
->parent
) {
598 obj
->parent
= http_message_object_new_ex(Z_OBJCE_P(getThis()), obj
->message
->parent
, NULL
);
601 obj
->message
= http_message_init(msg
);
605 obj
->message
= http_message_new();
611 /* {{{ proto static HttpMessage HttpMessage::fromString(string raw_message[, string class_name = "HttpMessage"])
613 * Create an HttpMessage object from a string. Kind of a static constructor.
615 * Expects a string parameter containing a single or several consecutive
616 * HTTP messages. Accepts an optional string parameter specifying the class to use.
618 * Returns an HttpMessage object on success or NULL on failure.
620 * Throws HttpMalformedHeadersException.
622 PHP_METHOD(HttpMessage
, fromString
)
624 char *string
= NULL
, *class_name
= NULL
;
625 int length
= 0, class_length
= 0;
626 http_message
*msg
= NULL
;
631 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s|s", &string
, &length
, &class_name
, &class_length
)) {
632 if ((msg
= http_message_parse(string
, length
))) {
633 zend_class_entry
*ce
= http_message_object_ce
;
635 if (class_name
&& *class_name
) {
636 ce
= zend_fetch_class(class_name
, class_length
, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC
);
637 if (ce
&& !instanceof_function(ce
, http_message_object_ce TSRMLS_CC
)) {
638 http_error_ex(HE_WARNING
, HTTP_E_RUNTIME
, "Class %s does not extend HttpMessage", class_name
);
643 RETVAL_OBJVAL(http_message_object_new_ex(ce
, msg
, NULL
), 0);
651 /* {{{ proto string HttpMessage::getBody()
653 * Get the body of the parsed HttpMessage.
655 * Returns the message body as string.
657 PHP_METHOD(HttpMessage
, getBody
)
662 getObject(http_message_object
, obj
);
663 RETURN_PHPSTR(&obj
->message
->body
, PHPSTR_FREE_NOT
, 1);
668 /* {{{ proto void HttpMessage::setBody(string body)
670 * Set the body of the HttpMessage.
671 * NOTE: Don't forget to update any headers accordingly.
673 * Expects a string parameter containing the new body of the message.
675 PHP_METHOD(HttpMessage
, setBody
)
679 getObject(http_message_object
, obj
);
681 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &body
, &len
)) {
682 phpstr_dtor(PHPSTR(obj
->message
));
683 phpstr_from_string_ex(PHPSTR(obj
->message
), body
, len
);
688 /* {{{ proto array HttpMessage::getHeaders()
690 * Get Message Headers.
692 * Returns an associative array containing the messages HTTP headers.
694 PHP_METHOD(HttpMessage
, getHeaders
)
700 getObject(http_message_object
, obj
);
702 INIT_ZARR(headers
, &obj
->message
->hdrs
);
703 array_init(return_value
);
704 array_copy(&headers
, return_value
);
709 /* {{{ proto void HttpMessage::setHeaders(array headers)
713 * Expects an associative array as parameter containing the new HTTP headers,
714 * which will replace *all* previous HTTP headers of the message.
716 PHP_METHOD(HttpMessage
, setHeaders
)
718 zval
*new_headers
, old_headers
;
719 getObject(http_message_object
, obj
);
721 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a/", &new_headers
)) {
725 zend_hash_clean(&obj
->message
->hdrs
);
726 INIT_ZARR(old_headers
, &obj
->message
->hdrs
);
727 array_copy(new_headers
, &old_headers
);
731 /* {{{ proto void HttpMessage::addHeaders(array headers[, bool append = false])
733 * Add headers. If append is true, headers with the same name will be separated, else overwritten.
735 * Expects an associative array as parameter containing the additional HTTP headers
736 * to add to the messages existing headers. If the optional bool parameter is true,
737 * and a header with the same name of one to add exists already, this respective
738 * header will be converted to an array containing both header values, otherwise
739 * it will be overwritten with the new header value.
741 PHP_METHOD(HttpMessage
, addHeaders
)
743 zval old_headers
, *new_headers
;
744 zend_bool append
= 0;
745 getObject(http_message_object
, obj
);
747 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "a|b", &new_headers
, &append
)) {
751 INIT_ZARR(old_headers
, &obj
->message
->hdrs
);
753 array_append(new_headers
, &old_headers
);
755 array_merge(new_headers
, &old_headers
);
760 /* {{{ proto int HttpMessage::getType()
762 * Get Message Type. (HTTP_MSG_NONE|HTTP_MSG_REQUEST|HTTP_MSG_RESPONSE)
764 * Returns the HttpMessage::TYPE.
766 PHP_METHOD(HttpMessage
, getType
)
771 getObject(http_message_object
, obj
);
772 RETURN_LONG(obj
->message
->type
);
777 /* {{{ proto void HttpMessage::setType(int type)
779 * Set Message Type. (HTTP_MSG_NONE|HTTP_MSG_REQUEST|HTTP_MSG_RESPONSE)
781 * Expects an int parameter, the HttpMessage::TYPE.
783 PHP_METHOD(HttpMessage
, setType
)
786 getObject(http_message_object
, obj
);
788 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &type
)) {
791 http_message_set_type(obj
->message
, type
);
795 /* {{{ proto int HttpMessage::getResponseCode()
797 * Get the Response Code of the Message.
799 * Returns the HTTP response code if the message is of type
800 * HttpMessage::TYPE_RESPONSE, else FALSE.
802 PHP_METHOD(HttpMessage
, getResponseCode
)
807 getObject(http_message_object
, obj
);
808 HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj
->message
, RETURN_FALSE
);
809 RETURN_LONG(obj
->message
->http
.info
.response
.code
);
814 /* {{{ proto bool HttpMessage::setResponseCode(int code)
816 * Set the response code of an HTTP Response Message.
818 * Expects an int parameter with the HTTP response code.
820 * Returns TRUE on success, or FALSE if the message is not of type
821 * HttpMessage::TYPE_RESPONSE or the response code is out of range (100-510).
823 PHP_METHOD(HttpMessage
, setResponseCode
)
826 getObject(http_message_object
, obj
);
828 HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj
->message
, RETURN_FALSE
);
830 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "l", &code
)) {
833 if (code
< 100 || code
> 510) {
834 http_error_ex(HE_WARNING
, HTTP_E_INVALID_PARAM
, "Invalid response code (100-510): %ld", code
);
838 obj
->message
->http
.info
.response
.code
= code
;
843 /* {{{ proto string HttpMessage::getResponseStatus()
845 * Get the Response Status of the message (i.e. the string following the response code).
847 * Returns the HTTP response status string if the message is of type
848 * HttpMessage::TYPE_RESPONSE, else FALSE.
850 PHP_METHOD(HttpMessage
, getResponseStatus
)
855 getObject(http_message_object
, obj
);
856 HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj
->message
, RETURN_FALSE
);
857 RETURN_STRING(obj
->message
->http
.info
.response
.status
, 1);
862 /* {{{ proto bool HttpMessage::setResponseStatus(string status)
864 * Set the Response Status of the HTTP message (i.e. the string following the response code).
866 * Expects a string parameter containing the response status text.
868 * Returns TRUE on success or FALSE if the message is not of type
869 * HttpMessage::TYPE_RESPONSE.
871 PHP_METHOD(HttpMessage
, setResponseStatus
)
875 getObject(http_message_object
, obj
);
877 HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj
->message
, RETURN_FALSE
);
879 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &status
, &status_len
)) {
882 STR_SET(obj
->message
->http
.info
.response
.status
, estrdup(status
));
887 /* {{{ proto string HttpMessage::getRequestMethod()
889 * Get the Request Method of the Message.
891 * Returns the request method name on success, or FALSE if the message is
892 * not of type HttpMessage::TYPE_REQUEST.
894 PHP_METHOD(HttpMessage
, getRequestMethod
)
899 getObject(http_message_object
, obj
);
900 HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj
->message
, RETURN_FALSE
);
901 RETURN_STRING(obj
->message
->http
.info
.request
.method
, 1);
906 /* {{{ proto bool HttpMessage::setRequestMethod(string method)
908 * Set the Request Method of the HTTP Message.
910 * Expects a string parameter containing the request method name.
912 * Returns TRUE on success, or FALSE if the message is not of type
913 * HttpMessage::TYPE_REQUEST or an invalid request method was supplied.
915 PHP_METHOD(HttpMessage
, setRequestMethod
)
919 getObject(http_message_object
, obj
);
921 HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj
->message
, RETURN_FALSE
);
923 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &method
, &method_len
)) {
926 if (method_len
< 1) {
927 http_error(HE_WARNING
, HTTP_E_INVALID_PARAM
, "Cannot set HttpMessage::requestMethod to an empty string");
930 if (SUCCESS
!= http_check_method(method
)) {
931 http_error_ex(HE_WARNING
, HTTP_E_REQUEST_METHOD
, "Unkown request method: %s", method
);
935 STR_SET(obj
->message
->http
.info
.request
.method
, estrndup(method
, method_len
));
940 /* {{{ proto string HttpMessage::getRequestUrl()
942 * Get the Request URL of the Message.
944 * Returns the request url as string on success, or FALSE if the message
945 * is not of type HttpMessage::TYPE_REQUEST.
947 PHP_METHOD(HttpMessage
, getRequestUrl
)
952 getObject(http_message_object
, obj
);
953 HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj
->message
, RETURN_FALSE
);
954 RETURN_STRING(obj
->message
->http
.info
.request
.url
, 1);
959 /* {{{ proto bool HttpMessage::setRequestUrl(string url)
961 * Set the Request URL of the HTTP Message.
963 * Expects a string parameters containing the request url.
965 * Returns TRUE on success, or FALSE if the message is not of type
966 * HttpMessage::TYPE_REQUEST or supplied URL was empty.
968 PHP_METHOD(HttpMessage
, setRequestUrl
)
972 getObject(http_message_object
, obj
);
974 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &URI
, &URIlen
)) {
977 HTTP_CHECK_MESSAGE_TYPE_REQUEST(obj
->message
, RETURN_FALSE
);
979 http_error(HE_WARNING
, HTTP_E_INVALID_PARAM
, "Cannot set HttpMessage::requestUrl to an empty string");
983 STR_SET(obj
->message
->http
.info
.request
.url
, estrndup(URI
, URIlen
));
988 /* {{{ proto string HttpMessage::getHttpVersion()
990 * Get the HTTP Protocol Version of the Message.
992 * Returns the HTTP protocol version as string.
994 PHP_METHOD(HttpMessage
, getHttpVersion
)
1000 getObject(http_message_object
, obj
);
1002 sprintf(ver
, "%1.1lf", obj
->message
->http
.version
);
1003 RETURN_STRINGL(ver
, 3, 1);
1008 /* {{{ proto bool HttpMessage::setHttpVersion(string version)
1010 * Set the HTTP Protocol version of the Message.
1012 * Expects a string parameter containing the HTTP protocol version.
1014 * Returns TRUE on success, or FALSE if supplied version is out of range (1.0/1.1).
1016 PHP_METHOD(HttpMessage
, setHttpVersion
)
1020 getObject(http_message_object
, obj
);
1022 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "z/", &zv
)) {
1026 convert_to_double(zv
);
1027 sprintf(v
, "%1.1lf", Z_DVAL_P(zv
));
1028 if (strcmp(v
, "1.0") && strcmp(v
, "1.1")) {
1029 http_error_ex(HE_WARNING
, HTTP_E_INVALID_PARAM
, "Invalid HTTP protocol version (1.0 or 1.1): %s", v
);
1033 obj
->message
->http
.version
= Z_DVAL_P(zv
);
1038 /* {{{ proto HttpMessage HttpMessage::getParentMessage()
1040 * Get parent Message.
1042 * Returns the parent HttpMessage on success, or NULL if there's none.
1044 PHP_METHOD(HttpMessage
, getParentMessage
)
1049 getObject(http_message_object
, obj
);
1051 if (obj
->message
->parent
) {
1052 RETVAL_OBJVAL(obj
->parent
, 1);
1060 /* {{{ proto bool HttpMessage::send()
1062 * Send the Message according to its type as Response or Request.
1063 * This provides limited functionality compared to HttpRequest and HttpResponse.
1065 * Returns TRUE on success, or FALSE on failure.
1067 PHP_METHOD(HttpMessage
, send
)
1069 getObject(http_message_object
, obj
);
1073 RETURN_SUCCESS(http_message_send(obj
->message
));
1077 /* {{{ proto string HttpMessage::toString([bool include_parent = false])
1079 * Get the string representation of the Message.
1081 * Accepts a bool parameter which specifies whether the returned string
1082 * should also contain any parent messages.
1084 * Returns the full message as string.
1086 PHP_METHOD(HttpMessage
, toString
)
1091 zend_bool include_parent
= 0;
1092 getObject(http_message_object
, obj
);
1094 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|b", &include_parent
)) {
1098 if (include_parent
) {
1099 http_message_serialize(obj
->message
, &string
, &length
);
1101 http_message_tostring(obj
->message
, &string
, &length
);
1103 RETURN_STRINGL(string
, length
, 0);
1108 /* {{{ proto HttpRequest|HttpResponse HttpMessage::toMessageTypeObject(void)
1110 * Creates an object regarding to the type of the message.
1112 * Returns either an HttpRequest or HttpResponse object on success, or NULL on failure.
1114 * Throws HttpRuntimeException, HttpMessageTypeException, HttpHeaderException.
1116 PHP_METHOD(HttpMessage
, toMessageTypeObject
)
1118 SET_EH_THROW_HTTP();
1123 getObject(http_message_object
, obj
);
1125 switch (obj
->message
->type
)
1127 case HTTP_MSG_REQUEST
:
1129 #ifdef HTTP_HAVE_CURL
1132 zval tmp
, body
, *array
, *headers
, *host
= http_message_header(obj
->message
, "Host");
1133 php_url hurl
, *purl
= php_url_parse(obj
->message
->http
.info
.request
.url
);
1135 MAKE_STD_ZVAL(array
);
1138 memset(&hurl
, 0, sizeof(php_url
));
1139 hurl
.host
= host
? Z_STRVAL_P(host
) : NULL
;
1140 http_build_url(HTTP_URL_REPLACE
, purl
, &hurl
, NULL
, &url
, NULL
);
1142 add_assoc_string(array
, "url", url
, 0);
1144 if ( (method
= http_request_method_exists(1, 0, obj
->message
->http
.info
.request
.method
)) ||
1145 (method
= http_request_method_register(obj
->message
->http
.info
.request
.method
, strlen(obj
->message
->http
.info
.request
.method
)))) {
1146 add_assoc_long(array
, "method", method
);
1149 if (10 == (int) (obj
->message
->http
.version
* 10)) {
1150 add_assoc_long(array
, "protocol", CURL_HTTP_VERSION_1_0
);
1153 MAKE_STD_ZVAL(headers
);
1154 array_init(headers
);
1155 INIT_ZARR(tmp
, &obj
->message
->hdrs
);
1156 array_copy(&tmp
, headers
);
1157 add_assoc_zval(array
, "headers", headers
);
1159 object_init_ex(return_value
, http_request_object_ce
);
1160 zend_call_method_with_1_params(&return_value
, http_request_object_ce
, NULL
, "setoptions", NULL
, array
);
1161 zval_ptr_dtor(&array
);
1164 ZVAL_STRINGL(&body
, PHPSTR_VAL(obj
->message
), PHPSTR_LEN(obj
->message
), 0);
1165 zend_call_method_with_1_params(&return_value
, http_request_object_ce
, NULL
, "setrawpostdata", NULL
, &body
);
1167 http_error(HE_WARNING
, HTTP_E_RUNTIME
, "Cannot transform HttpMessage to HttpRequest (missing curl support)");
1172 case HTTP_MSG_RESPONSE
:
1175 HashPosition pos1
, pos2
;
1179 zval
**header
, **h
, *body
;
1181 if (obj
->message
->http
.info
.response
.code
) {
1182 http_send_status(obj
->message
->http
.info
.response
.code
);
1185 object_init_ex(return_value
, http_response_object_ce
);
1187 FOREACH_HASH_KEYLENVAL(pos1
, &obj
->message
->hdrs
, key
, key_len
, idx
, header
) {
1192 ZVAL_STRINGL(&zkey
, key
, key_len
, 0);
1194 switch (Z_TYPE_PP(header
))
1198 FOREACH_HASH_VAL(pos2
, HASH_OF(*header
), h
) {
1200 zend_call_method_with_2_params(&return_value
, http_response_object_ce
, NULL
, "setheader", NULL
, &zkey
, *h
);
1206 ZVAL_ADDREF(*header
);
1207 zend_call_method_with_2_params(&return_value
, http_response_object_ce
, NULL
, "setheader", NULL
, &zkey
, *header
);
1208 zval_ptr_dtor(header
);
1215 MAKE_STD_ZVAL(body
);
1216 ZVAL_STRINGL(body
, PHPSTR_VAL(obj
->message
), PHPSTR_LEN(obj
->message
), 1);
1217 zend_call_method_with_1_params(&return_value
, http_response_object_ce
, NULL
, "setdata", NULL
, body
);
1218 zval_ptr_dtor(&body
);
1220 http_error(HE_WARNING
, HTTP_E_RUNTIME
, "Cannot transform HttpMessage to HttpResponse (need PHP 5.1+)");
1226 http_error(HE_WARNING
, HTTP_E_MESSAGE_TYPE
, "HttpMessage is neither of type HttpMessage::TYPE_REQUEST nor HttpMessage::TYPE_RESPONSE");
1234 /* {{{ proto int HttpMessage::count()
1236 * Implements Countable.
1238 * Returns the number of parent messages + 1.
1240 PHP_METHOD(HttpMessage
, count
)
1245 getObject(http_message_object
, obj
);
1247 for (i
= 0, msg
= obj
->message
; msg
; msg
= msg
->parent
, ++i
);
1253 /* {{{ proto string HttpMessage::serialize()
1255 * Implements Serializable.
1257 * Returns the serialized representation of the HttpMessage.
1259 PHP_METHOD(HttpMessage
, serialize
)
1264 getObject(http_message_object
, obj
);
1266 http_message_serialize(obj
->message
, &string
, &length
);
1267 RETURN_STRINGL(string
, length
, 0);
1272 /* {{{ proto void HttpMessage::unserialize(string serialized)
1274 * Implements Serializable.
1276 * Re-constructs the HttpMessage based upon the serialized string.
1278 PHP_METHOD(HttpMessage
, unserialize
)
1282 getObject(http_message_object
, obj
);
1284 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &serialized
, &length
)) {
1285 http_message_dtor(obj
->message
);
1286 if (!http_message_parse_ex(obj
->message
, serialized
, (size_t) length
)) {
1287 http_error(HE_ERROR
, HTTP_E_RUNTIME
, "Could not unserialize HttpMessage");
1288 http_message_init(obj
->message
);
1294 /* {{{ proto HttpMessage HttpMessage::detach(void)
1296 * Returns a clone of an HttpMessage object detached from any parent messages.
1298 PHP_METHOD(HttpMessage
, detach
)
1302 getObject(http_message_object
, obj
);
1306 info
.type
= obj
->message
->type
;
1307 memcpy(&HTTP_INFO(&info
), &HTTP_INFO(obj
->message
), sizeof(struct http_info
));
1309 msg
= http_message_new();
1310 http_message_set_info(msg
, &info
);
1312 zend_hash_copy(&msg
->hdrs
, &obj
->message
->hdrs
, (copy_ctor_func_t
) zval_add_ref
, NULL
, sizeof(zval
*));
1313 phpstr_append(&msg
->body
, PHPSTR_VAL(obj
->message
), PHPSTR_LEN(obj
->message
));
1315 RETVAL_OBJVAL(http_message_object_new_ex(Z_OBJCE_P(getThis()), msg
, NULL
), 0);
1319 /* {{{ proto void HttpMessage::prepend(HttpMessage message)
1321 * Prepends message(s) to the HTTP message.
1323 * Expects an HttpMessage object as parameter.
1325 PHP_METHOD(HttpMessage
, prepend
)
1330 if (SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "O|b", &prepend
, http_message_object_ce
, &top
)) {
1332 http_message
*save_parent_msg
;
1333 zend_object_value save_parent_obj
;
1334 getObject(http_message_object
, obj
);
1335 getObjectEx(http_message_object
, prepend_obj
, prepend
);
1341 save_parent_obj
= obj
->parent
;
1342 save_parent_msg
= obj
->message
->parent
;
1344 /* iterate to the most parent object */
1345 while (obj
->parent
.handle
) {
1346 m
.value
.obj
= obj
->parent
;
1347 obj
= zend_object_store_get_object(&m TSRMLS_CC
);
1352 obj
->parent
= prepend
->value
.obj
;
1353 obj
->message
->parent
= prepend_obj
->message
;
1356 zend_objects_store_add_ref(prepend TSRMLS_CC
);
1357 while (prepend_obj
->parent
.handle
) {
1358 m
.value
.obj
= prepend_obj
->parent
;
1359 zend_objects_store_add_ref(&m TSRMLS_CC
);
1360 prepend_obj
= zend_object_store_get_object(&m TSRMLS_CC
);
1364 prepend_obj
->parent
= save_parent_obj
;
1365 prepend_obj
->message
->parent
= save_parent_msg
;
1371 /* {{{ proto void HttpMessage::rewind(void)
1373 * Implements Iterator.
1375 PHP_METHOD(HttpMessage
, rewind
)
1378 getObject(http_message_object
, obj
);
1380 if (obj
->iterator
) {
1381 zval_ptr_dtor(&obj
->iterator
);
1383 ZVAL_ADDREF(getThis());
1384 obj
->iterator
= getThis();
1389 /* {{{ proto bool HttpMessage::valid(void)
1391 * Implements Iterator.
1393 PHP_METHOD(HttpMessage
, valid
)
1396 getObject(http_message_object
, obj
);
1398 RETURN_BOOL(obj
->iterator
!= NULL
);
1403 /* {{{ proto void HttpMessage::next(void)
1405 * Implements Iterator.
1407 PHP_METHOD(HttpMessage
, next
)
1410 getObject(http_message_object
, obj
);
1411 getObjectEx(http_message_object
, itr
, obj
->iterator
);
1413 if (itr
&& itr
->parent
.handle
) {
1414 zval
*old
= obj
->iterator
;
1415 MAKE_STD_ZVAL(obj
->iterator
);
1416 ZVAL_OBJVAL(obj
->iterator
, itr
->parent
, 1);
1417 zval_ptr_dtor(&old
);
1419 zval_ptr_dtor(&obj
->iterator
);
1420 obj
->iterator
= NULL
;
1426 /* {{{ proto int HttpMessage::key(void)
1428 * Implements Iterator.
1430 PHP_METHOD(HttpMessage
, key
)
1433 getObject(http_message_object
, obj
);
1435 RETURN_LONG(obj
->iterator
? obj
->iterator
->value
.obj
.handle
:0);
1440 /* {{{ proto HttpMessage HttpMessage::current(void)
1442 * Implements Iterator.
1444 PHP_METHOD(HttpMessage
, current
)
1447 getObject(http_message_object
, obj
);
1449 if (obj
->iterator
) {
1450 RETURN_ZVAL(obj
->iterator
, 1, 0);
1456 #endif /* ZEND_ENGINE_2 */
1463 * vim600: noet sw=4 ts=4 fdm=marker
1464 * vim<600: noet sw=4 ts=4