nbsp; //先进行试探性读取 int len=read(clientFd,buf,BUF_SIZE);
printf("%s",buf);
if(len>0)
{
char *token=strtok(buf," "); //GET
printf("token:%s",token);
char type[64];
char *url=strtok(NULL," "); //URL
while(*url=='.'||*url=='/')++url;
printf("url:%s",url);
char file[1280000];
sprintf(file,"%s",url);
printf("file:%s",file);
FILE *fp=fopen(file,"rb");
if(fp==0)
{
char response[]="HTTP/1.1 404 NOT FOUND\r\n\r\n";
printf("HTTP/1.1 404 NOT FOUND\r\n\r\n");
write(clientFd,response,strlen(response));
}
else
{
int file_size;
char *content;
char *response;
fseek(fp,0,SEEK_END);
file_size=ftell(fp);
&n