Skip to content

Commit f0d4653

Browse files
committed
Added convert_to_string.
1 parent 12c1200 commit f0d4653

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

swoole_server.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,11 @@ int php_swoole_get_send_data(zval *zdata, char **str TSRMLS_DC)
101101
{
102102
int length;
103103

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)
110105
{
111106
if (!instanceof_function(Z_OBJCE_P(zdata), swoole_buffer_class_entry_ptr TSRMLS_CC))
112107
{
113-
swoole_php_fatal_error(E_WARNING, "object is not instanceof swoole_buffer.");
114-
return SW_ERR;
108+
goto convert;
115109
}
116110
swString *str_buffer = swoole_get_object(zdata);
117111
if (!str_buffer->str)
@@ -124,8 +118,10 @@ int php_swoole_get_send_data(zval *zdata, char **str TSRMLS_DC)
124118
}
125119
else
126120
{
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);
129125
}
130126

131127
if (length >= SwooleG.serv->buffer_output_size)
@@ -2168,7 +2164,7 @@ PHP_FUNCTION(swoole_server_sendfile)
21682164
}
21692165
else
21702166
{
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)
21722168
{
21732169
return;
21742170
}

0 commit comments

Comments
 (0)