@@ -101,17 +101,11 @@ int php_swoole_get_send_data(zval *zdata, char **str TSRMLS_DC)
101
101
{
102
102
int length ;
103
103
104
- if (SW_Z_TYPE_P (zdata ) == IS_STRING )
105
- {
106
- length = Z_STRLEN_P (zdata );
107
- * str = Z_STRVAL_P (zdata );
108
- }
109
- else if (SW_Z_TYPE_P (zdata ) == IS_OBJECT )
104
+ if (SW_Z_TYPE_P (zdata ) == IS_OBJECT )
110
105
{
111
106
if (!instanceof_function (Z_OBJCE_P (zdata ), swoole_buffer_class_entry_ptr TSRMLS_CC ))
112
107
{
113
- swoole_php_fatal_error (E_WARNING , "object is not instanceof swoole_buffer." );
114
- return SW_ERR ;
108
+ goto convert ;
115
109
}
116
110
swString * str_buffer = swoole_get_object (zdata );
117
111
if (!str_buffer -> str )
@@ -124,8 +118,10 @@ int php_swoole_get_send_data(zval *zdata, char **str TSRMLS_DC)
124
118
}
125
119
else
126
120
{
127
- swoole_php_fatal_error (E_WARNING , "only supports string or swoole_buffer type." );
128
- return SW_ERR ;
121
+ convert :
122
+ convert_to_string (zdata );
123
+ length = Z_STRLEN_P (zdata );
124
+ * str = Z_STRVAL_P (zdata );
129
125
}
130
126
131
127
if (length >= SwooleG .serv -> buffer_output_size )
@@ -2168,7 +2164,7 @@ PHP_FUNCTION(swoole_server_sendfile)
2168
2164
}
2169
2165
else
2170
2166
{
2171
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ls" , & conn_fd , & filename , & send_data . info . len ) == FAILURE )
2167
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ls" , & conn_fd , & filename , & len ) == FAILURE )
2172
2168
{
2173
2169
return ;
2174
2170
}
0 commit comments