轻量HTTP
轻量的http服务器
梅杏柿
这个作者很懒,什么都没留下…
展开
-
简单http学习:5 excute_cgi调用
void execute_cgi(int client, const char *path, const char *method, const char *query_string){ char buf[1024]; int cgi_output[2]; int cgi_input[2]; pid_t pid; int status; int i; char c; int numchars = 1; int content_lengt原创 2021-03-27 21:13:07 · 165 阅读 · 0 评论 -
简单http学习:4 server_file 函数
void serve_file(int client, const char *filename){FILE *resource = NULL;int numchars = 1;char buf[1024];buf[0] = ‘A’;buf[1] = ‘\0’;//这里设置的意义是什么,保证进入循环while ((numchars > 0) && strcmp("\n", buf)) /* read & discard headers */numchars =原创 2021-03-27 21:11:13 · 342 阅读 · 0 评论 -
简单http学习:3 accept_request 函数
重头void accept_request(int client){ char buf[1024]; int numchars; char method[255]; char url[255]; char path[512]; size_t i, j; struct stat st; /* int stat( const char *filename //文件或者文件夹的路径 , struct stat *buf //获取的信息保存在内存中)原创 2021-03-27 21:10:46 · 455 阅读 · 1 评论 -
简单http学习:2 错误函数
void unimplemented(int client){//回答不能执行的方法 char buf[1024]; //sprintf格式化输出字符串,printf的兄弟,区别在于spintf是输出到了目标缓冲区 //状态行 //http/1.1版本号 501错误代码 及原因 /* 状态代码有三位数字组成,第一个数字定义了响应的类别,共分五种类别: 1xx:指示信息--表示请求已接收,继续处理 2xx:成功--表示请求已被成功接收、理解、接受 3xx:重定向--要完原创 2021-03-27 21:06:15 · 102 阅读 · 0 评论 -
简单http学习:1 总体概述
#include <stdio.h>#include <sys/socket.h>#include <sys/types.h>#include <netinet/in.h>#include <arpa/inet.h>#include <unistd.h>#include <ctype.h>#include <strings.h>#include <string.h>#include原创 2021-03-27 21:03:13 · 67 阅读 · 0 评论