From: Michael Wallner Date: Thu, 21 Jul 2005 15:37:20 +0000 (+0000) Subject: - fix output buffering, default mime type X-Git-Tag: RELEASE_0_10_0~31 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=653bb2f74eabb04af4e711fbc8d3d51e606649f7;p=m6w6%2Fext-http - fix output buffering, default mime type - get rid of unused macros --- diff --git a/http_response_object.c b/http_response_object.c index aee8612..e345cfe 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -353,7 +353,7 @@ PHP_METHOD(HttpResponse, setContentDisposition) } spprintf(&cd, 0, HTTP_CONTENTDISPOSITION_TEMPLATE, send_inline ? "inline" : "attachment", file); - ZVAL_STRING_FREE(GET_STATIC_PROP(contentDisposition), cd, 0); + SET_STATIC_PROP_STRING(contentDisposition, cd, 0); RETURN_TRUE; } /* }}} */ @@ -386,7 +386,8 @@ PHP_METHOD(HttpResponse, setETag) RETURN_FALSE; } - ZVAL_STRINGL_FREE(GET_STATIC_PROP(eTag), etag, etag_len, 1); + USE_STATIC_PROP(); + SET_STATIC_PROP_STRINGL(eTag, etag, etag_len, 1); RETURN_TRUE; } /* }}} */ @@ -584,12 +585,14 @@ PHP_METHOD(HttpResponse, send) /* interrupt on-the-fly etag generation */ HTTP_G(etag).started = 0; /* discard previous output buffers */ - //php_end_ob_buffers(0 TSRMLS_CC); + php_end_ob_buffers(0 TSRMLS_CC); } /* gzip */ if (Z_LVAL_P(GET_STATIC_PROP(gzip))) { php_start_ob_buffer_named("ob_gzhandler", 0, 1 TSRMLS_CC); + } else { + php_start_ob_buffer(NULL, 0, 0 TSRMLS_CC); } /* caching */ @@ -602,7 +605,7 @@ PHP_METHOD(HttpResponse, send) lmod = GET_STATIC_PROP(lastModified); cctl = GET_STATIC_PROP(cacheControl); - http_cache_etag(Z_STRVAL_P(etag), Z_STRLEN_P(etag),Z_STRVAL_P(cctl), Z_STRLEN_P(cctl)); + http_cache_etag(Z_STRVAL_P(etag), Z_STRLEN_P(etag), Z_STRVAL_P(cctl), Z_STRLEN_P(cctl)); http_cache_last_modified(Z_LVAL_P(lmod), Z_LVAL_P(lmod) ? Z_LVAL_P(lmod) : time(NULL), Z_STRVAL_P(cctl), Z_STRLEN_P(cctl)); } @@ -612,7 +615,14 @@ PHP_METHOD(HttpResponse, send) if (Z_STRLEN_P(ctype)) { http_send_content_type(Z_STRVAL_P(ctype), Z_STRLEN_P(ctype)); } else { - http_send_content_type("application/x-octetstream", lenof("application/x-octetstream")); + char *ctypes = INI_STR("default_mimetype"); + size_t ctlen = ctypes ? strlen(ctypes) : 0; + + if (ctlen) { + http_send_content_type(ctypes, ctlen); + } else { + http_send_content_type("application/x-octetstream", lenof("application/x-octetstream")); + } } } diff --git a/php_http_std_defs.h b/php_http_std_defs.h index e6d76d7..9b17bcc 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -41,19 +41,6 @@ typedef int STATUS; if(target) efree(target); \ target = source -#define ZVAL_STRING_FREE(z, s, d) \ - {\ - zval *__tmp = (z); \ - /*zval_ptr_dtor(&__tmp);*/ \ - ZVAL_STRING(__tmp, (s), (d)); \ - } -#define ZVAL_STRINGL_FREE(z, s, l, d) \ - {\ - zval *__tmp = (z); \ - /*zval_ptr_dtor(&__tmp);*/ \ - ZVAL_STRINGL(__tmp, (s), (l), (d)); \ - } - /* return bool (v == SUCCESS) */ #define RETVAL_SUCCESS(v) RETVAL_BOOL(SUCCESS == (v)) #define RETURN_SUCCESS(v) RETURN_BOOL(SUCCESS == (v)) @@ -232,6 +219,7 @@ typedef int STATUS; MAKE_STD_ZVAL(__tmp); \ ZVAL_STRING(__tmp, (s), (d)); \ SET_STATIC_PROP_EX(ce, n, __tmp); \ + zval_dtor(__tmp); \ efree(__tmp); \ } #define SET_STATIC_PROP_STRINGL_EX(ce, n, s, l, d) \ @@ -240,6 +228,7 @@ typedef int STATUS; MAKE_STD_ZVAL(__tmp); \ ZVAL_STRINGL(__tmp, (s), (l), (d)); \ SET_STATIC_PROP_EX(ce, n, __tmp); \ + zval_dtor(__tmp); \ efree(__tmp); \ } # define DCL_PROP(a, t, n, v) zend_declare_property_ ##t(ce, (#n), sizeof(#n), (v), (ZEND_ACC_ ##a) TSRMLS_CC)