-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
148 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
## Tccgi | ||
|
||
简单的玩具型http服务器,支持基础的cgi请求。通过[tcc](http://bellard.org/tcc/)编译。 | ||
|
||
### 构建: | ||
|
||
`winsock2.h` 来自MinGW项目的win32API。 | ||
依赖`ws2_32.dll`,使用: | ||
``` | ||
tiny_imdef.exe ws2_32.dll | ||
``` | ||
生成`ws2_32.def` 执行: | ||
``` | ||
tcc.exe server.c ws2_32.def | ||
``` | ||
构建完成:) | ||
|
||
### 支持程度: | ||
|
||
普通静态文件(限制大小512kB),cgi输出(512kB)。 | ||
仅支持`GET`请求 | ||
支持的环境变量: | ||
``` | ||
SERVER_NAME | ||
QUERY_STRING | ||
SERVER_SOFTWARE | ||
GATEWAY_INTERFACE | ||
SERVER_PROTOCOL | ||
REQUEST_METHOD | ||
PATH_INFO | ||
SCRIPT_NAME | ||
REMOTE_ADDR | ||
REMOTE_PORT | ||
``` | ||
|
||
cgi支持`Content-Type`与`Status`头部,不支持`Location`头 | ||
|
||
### 执行: | ||
``` | ||
server.exe [-d www_root | -p port | -t cgi_timeout | -e cgi_extname] | ||
Usage: | ||
-d root directory | ||
-p port default port is 9527 | ||
-t cgi timeout default is 3 seconds | ||
-e extname default is cgi | ||
``` | ||
|
||
### License : WTFPL | ||
|
||
``` | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> | ||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
0. You just DO WHAT THE FUCK YOU WANT TO. | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <windows.h> | ||
|
||
#define PRINT_ENV(x) {printf("<b>%s</b> : %s<br>", x, getenv(x));} | ||
|
||
void EnumEnvironment() { | ||
PRINT_ENV("SERVER_NAME"); | ||
PRINT_ENV("QUERY_STRING"); | ||
PRINT_ENV("SERVER_SOFTWARE"); | ||
PRINT_ENV("GATEWAY_INTERFACE"); | ||
PRINT_ENV("SERVER_PROTOCOL"); | ||
PRINT_ENV("REQUEST_METHOD"); | ||
PRINT_ENV("PATH_INFO"); | ||
PRINT_ENV("SCRIPT_NAME"); | ||
PRINT_ENV("REMOTE_ADDR"); | ||
PRINT_ENV("REMOTE_PORT"); | ||
} | ||
|
||
int main(int argc, char* argv[]) { | ||
printf("Content-Type: text/html; charset=utf-8\nX-CGI-test:1234345\n\n"); | ||
char* query_string = getenv("QUERY_STRING"); | ||
printf("<!DOCTYPE html><h1>It works!</h1>"); | ||
int i = 0; | ||
if (argc > 0) printf("<h3>args</h3>"); | ||
while(argc > 0) { | ||
printf("<h4><b>%d.</b> %s</h4>", i+1, argv[i]); | ||
++i; argc--; | ||
} | ||
printf("<h3>Environment:</h3>"); | ||
EnumEnvironment(); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | ||
"http://www.w3.org/TR/html4/loose.dtd"> | ||
<html> | ||
<head> | ||
<title></title> | ||
</head> | ||
<body> | ||
<h1>It works!</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters