深入理解计算机系统 CSAPP 家庭作业11.7

静态内容是指在不同请求中访问到的数据都相同的静态文件。例如:图片、视频、网站中的文件(html、css、js)、软件安装包、apk文件、压缩包文件等。

复制代码
/*
 * get_filetype - derive file type from file name
 */
void get_filetype(char *filename, char *filetype) 
{
    if (strstr(filename, ".html"))
	strcpy(filetype, "text/html");
    else if (strstr(filename, ".gif"))
	strcpy(filetype, "image/gif");
    else if (strstr(filename, ".png"))
	strcpy(filetype, "image/png");
    else if (strstr(filename, ".jpg"))
	strcpy(filetype, "image/jpeg");
	else if (strstr(filename, ".mpg"))
	strcpy(filetype, "video/mpg");
    else
	strcpy(filetype, "text/plain");
}  
/* $end serve_static */
相关推荐
码农客栈2 分钟前
Linux CAN 驱动
linux·驱动开发
GeW2 小时前
红帽RHCE从挂科边缘到一次过,我做对了什么
linux
时空自由民.2 小时前
WSL解决USB 串口连接问题与linux串口权限问题
linux·单片机
OpenPomeloxCommunity2 小时前
Linux驱动基础(三):firmware的声明与加载
linux·操作系统
云计算练习生2 小时前
什么是系统调用?为什么程序访问硬件必须经过它
linux·windows·操作系统·系统调用·操作系统原理
玄芯散人3 小时前
【筑基·059】Linux命令行入门:工程师的操作系统
linux·操作系统·命令行
半仙白桑3 小时前
内核篇第二讲:Linux exec 函数族详解
linux·linux驱动
AR-26710-3 小时前
Linux Day7——建组/用户、umask、Python脚本
linux·python
吴声子夜歌4 小时前
Shell编程实例——内务及管理任务(一)
linux·运维·shell
byte轻骑兵4 小时前
【BlueZ 】input 模块:蓝牙鼠标/键盘等输入设备的基础适配逻辑
linux·人工智能·bluez·电脑蓝牙·嵌入式蓝牙