- fix output buffering, default mime type
authorMichael Wallner <mike@php.net>
Thu, 21 Jul 2005 15:37:20 +0000 (15:37 +0000)
committerMichael Wallner <mike@php.net>
Thu, 21 Jul 2005 15:37:20 +0000 (15:37 +0000)
- get rid of unused macros

http_response_object.c
php_http_std_defs.h

index aee8612c182f63866b667df88da979aa6435fb6a..e345cfe1c39ec1b76487b1d6d0f0c2977ca21eb2 100644 (file)
@@ -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"));
+                       }
                }
        }
 
index e6d76d77566e50ef09cfe5ba355de098a5492ef7..9b17bccab0fe86898341c9a64f2a10f2c0097789 100644 (file)
@@ -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)