X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_response_object.c;h=93c8f0c82193ca56993cb02928a12f21c017b707;hp=61b3c82353220524775c7830ba036c8dcc7ccf11;hb=ffc893b125c6cc9b385a68a357b08ba2cc4e91f6;hpb=c07ee6eaef449abb292bb84d5ba61c19a467e184 diff --git a/http_response_object.c b/http_response_object.c index 61b3c82..93c8f0c 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -41,6 +41,9 @@ #ifdef HTTP_HAVE_MHASH # include #endif +#ifdef HTTP_HAVE_MAGIC +# include +#endif ZEND_EXTERN_MODULE_GLOBALS(http); @@ -240,6 +243,7 @@ static inline void _http_response_object_declare_default_properties(TSRMLS_D) #ifndef WONKY DCL_CONST(long, "ETAG_MD5", HTTP_ETAG_MD5); DCL_CONST(long, "ETAG_SHA1", HTTP_ETAG_SHA1); + DCL_CONST(long, "ETAG_CRC32", HTTP_ETAG_CRC32); # ifdef HTTP_HAVE_MHASH { @@ -499,7 +503,7 @@ PHP_METHOD(HttpResponse, getContentType) } /* }}} */ -/* {{{ proto static string HttpResponse::guessContentType(string magic_file[, long magic_mode]) +/* {{{ proto static string HttpResponse::guessContentType(string magic_file[, long magic_mode = MAGIC_MIME]) * * Attempts to guess the content type of supplied payload through libmagic. */ @@ -511,6 +515,9 @@ PHP_METHOD(HttpResponse, guessContentType) RETVAL_NULL(); +#ifdef HTTP_HAVE_MAGIC + magic_mode = MAGIC_MIME; + SET_EH_THROW_HTTP(); if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &magic_file, &magic_file_len, &magic_mode)) { switch (Z_LVAL_P(GET_STATIC_PROP(mode))) { @@ -541,6 +548,9 @@ PHP_METHOD(HttpResponse, guessContentType) } } SET_EH_NORMAL(); +#else + http_error(HE_THROW, HTTP_E_RUNTIME, "Cannot guess Content-Type; libmagic not available"); +#endif } /* }}} */