return buf;
}
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(php_http_buffer_t *buf, const char *string, size_t length)
+PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(
+ php_http_buffer_t *buf, const char *str, size_t len)
{
+ int free_buf = !!buf;
+
if ((buf = php_http_buffer_init(buf))) {
- if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(buf, string, length)) {
+ if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(buf, str, len)) {
- pefree(buf, buf->pmem);
+ if (free_buf) {
+ pefree(buf, buf->pmem);
+ }
buf = NULL;
}
}
return ret;
}
- if ((zoption = get_option(options, ZEND_STRL("headers") TSRMLS_CC))) {
+ if ((zoption = get_option(options, ZEND_STRL("headers"), &zoption_tmp))) {
if (Z_TYPE_P(zoption) == IS_ARRAY) {
- php_http_header_to_callback(Z_ARRVAL_P(zoption), 0, (php_http_pass_format_callback_t) r->ops->set_header, r TSRMLS_CC);
+ php_http_header_to_callback(Z_ARRVAL_P(zoption), 0, (php_http_pass_format_callback_t) r->ops->set_header, r);
}
- zval_ptr_dtor(&zoption);
+ zval_ptr_dtor(zoption);
}
- if (ret != SUCCESS) {
- return ret;
- }
-
- if ((zoption = get_option(options, ZEND_STRL("responseCode") TSRMLS_CC))) {
- zval *zoption_copy = php_http_ztyp(IS_LONG, zoption);
+ if ((zoption = get_option(options, ZEND_STRL("responseCode"), &zoption_tmp))) {
+ zend_long rc = zval_get_long(zoption);
- zval_ptr_dtor(&zoption);
- if (Z_LVAL_P(zoption_copy) > 0) {
- ret = r->ops->set_status(r, Z_LVAL_P(zoption_copy));
+ zval_ptr_dtor(zoption);
+ if (rc > 0) {
+ ret = r->ops->set_status(r, rc);
}
- zval_ptr_dtor(&zoption_copy);
}
if (ret != SUCCESS) {
#endif
nxt = ptr->next;
- php_stream_bucket_unlink(ptr TSRMLS_CC);
+ php_stream_bucket_unlink(ptr);
- php_http_encoding_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len);
+ if (SUCCESS != php_http_encoding_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len)) {
+ return PSFS_ERR_FATAL;
+ }
#if DBG_FILTER
fprintf(stderr, "update: deflate (-> %zu) (w: %zu, r: %zu)\n", encoded_len, stream->writepos, stream->readpos);