通过Apache 访问一个PHP文件,默认的content-type为 text/html , 如果通过PHP输入其他类型的内容需要通过header来设置,那么默认的content-type 是在什么地方做的呢?
1 2 3 4 5 6 7 |
#define SAPI_HEADER_SENT_SUCCESSFULLY 1 #define SAPI_HEADER_DO_SEND 2 #define SAPI_HEADER_SEND_FAILED 3 #define SAPI_DEFAULT_MIMETYPE "text/html" #define SAPI_DEFAULT_CHARSET "" #define SAPI_PHP_VERSION_HEADER "X-Powered-By: PHP/" PHP_VERSION |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
SAPI_API char *sapi_get_default_content_type(TSRMLS_D) { char *mimetype, *charset, *content_type; mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE; charset = SG(default_charset) ? SG(default_charset) : SAPI_DEFAULT_CHARSET; if (strncasecmp(mimetype, "text/", 5) == 0 && *charset) { int len = strlen(mimetype) + sizeof("; charset=") + strlen(charset); /* sizeof() includes \0 */ content_type = emalloc(len); snprintf(content_type, len, "%s; charset=%s", mimetype, charset); } else { content_type = estrdup(mimetype); } return content_type; } |