+
+ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessageBody_etag, 0, 0, 0)
+ZEND_END_ARG_INFO();
+PHP_METHOD(HttpMessageBody, etag)
+{
+ if (SUCCESS == zend_parse_parameters_none()) {
+ php_http_message_body_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
+ char *etag;
+
+ PHP_HTTP_MESSAGE_BODY_OBJECT_INIT(obj);
+
+ if ((etag = php_http_message_body_etag(obj->body))) {
+ RETURN_STR(php_http_cs2zs(etag, strlen(etag)));
+ } else {
+ RETURN_FALSE;
+ }
+ }
+}
+
+ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessageBody_stat, 0, 0, 0)
+ ZEND_ARG_INFO(0, field)
+ZEND_END_ARG_INFO();
+PHP_METHOD(HttpMessageBody, stat)
+{
+ char *field_str = NULL;
+ size_t field_len = 0;
+
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_str, &field_len)) {
+ php_http_message_body_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
+ const php_stream_statbuf *sb;
+
+ PHP_HTTP_MESSAGE_BODY_OBJECT_INIT(obj);
+
+ if ((sb = php_http_message_body_stat(obj->body))) {
+ if (field_str && field_len) {
+ switch (*field_str) {
+ case 's':
+ case 'S':
+ RETURN_LONG(sb->sb.st_size);
+ break;
+ case 'a':
+ case 'A':
+ RETURN_LONG(sb->sb.st_atime);
+ break;
+ case 'm':
+ case 'M':
+ RETURN_LONG(sb->sb.st_mtime);
+ break;
+ case 'c':
+ case 'C':
+ RETURN_LONG(sb->sb.st_ctime);
+ break;
+ default:
+ php_error_docref(NULL, E_WARNING, "Unknown stat field: '%s' (should be one of [s]ize, [a]time, [m]time or [c]time)", field_str);
+ break;
+ }
+ } else {
+ object_init(return_value);
+ add_property_long_ex(return_value, ZEND_STRL("size"), sb->sb.st_size);
+ add_property_long_ex(return_value, ZEND_STRL("atime"), sb->sb.st_atime);
+ add_property_long_ex(return_value, ZEND_STRL("mtime"), sb->sb.st_mtime);
+ add_property_long_ex(return_value, ZEND_STRL("ctime"), sb->sb.st_ctime);
+ }
+ }
+ }
+}
+
+static zend_function_entry php_http_message_body_methods[] = {
+ PHP_ME(HttpMessageBody, __construct, ai_HttpMessageBody___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
+ PHP_ME(HttpMessageBody, __toString, ai_HttpMessageBody___toString, ZEND_ACC_PUBLIC)
+ PHP_MALIAS(HttpMessageBody, toString, __toString, ai_HttpMessageBody___toString, ZEND_ACC_PUBLIC)
+ PHP_MALIAS(HttpMessageBody, serialize, __toString, ai_HttpMessageBody___toString, ZEND_ACC_PUBLIC)
+ PHP_ME(HttpMessageBody, unserialize, ai_HttpMessageBody_unserialize, ZEND_ACC_PUBLIC)
+ PHP_ME(HttpMessageBody, toStream, ai_HttpMessageBody_toStream, ZEND_ACC_PUBLIC)
+ PHP_ME(HttpMessageBody, toCallback, ai_HttpMessageBody_toCallback, ZEND_ACC_PUBLIC)
+ PHP_ME(HttpMessageBody, getResource, ai_HttpMessageBody_getResource, ZEND_ACC_PUBLIC)
+ PHP_ME(HttpMessageBody, getBoundary, ai_HttpMessageBody_getBoundary, ZEND_ACC_PUBLIC)
+ PHP_ME(HttpMessageBody, append, ai_HttpMessageBody_append, ZEND_ACC_PUBLIC)
+ PHP_ME(HttpMessageBody, addForm, ai_HttpMessageBody_addForm, ZEND_ACC_PUBLIC)
+ PHP_ME(HttpMessageBody, addPart, ai_HttpMessageBody_addPart, ZEND_ACC_PUBLIC)
+ PHP_ME(HttpMessageBody, etag, ai_HttpMessageBody_etag, ZEND_ACC_PUBLIC)
+ PHP_ME(HttpMessageBody, stat, ai_HttpMessageBody_stat, ZEND_ACC_PUBLIC)
+ EMPTY_FUNCTION_ENTRY
+};
+
+zend_class_entry *php_http_message_body_class_entry;
+
+PHP_MINIT_FUNCTION(http_message_body)
+{
+ zend_class_entry ce = {0};
+
+ INIT_NS_CLASS_ENTRY(ce, "http\\Message", "Body", php_http_message_body_methods);
+ php_http_message_body_class_entry = zend_register_internal_class(&ce);
+ php_http_message_body_class_entry->create_object = php_http_message_body_object_new;
+ memcpy(&php_http_message_body_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ php_http_message_body_object_handlers.offset = XtOffsetOf(php_http_message_body_object_t, zo);
+ php_http_message_body_object_handlers.clone_obj = php_http_message_body_object_clone;
+ php_http_message_body_object_handlers.free_obj = php_http_message_body_object_free;
+ zend_class_implements(php_http_message_body_class_entry, 1, zend_ce_serializable);
+
+ return SUCCESS;
+}
+