Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BEGIN {
- root = "./"
- sock = "/inet4/tcp/8080/0/0";
- while(1) {
- print "listennig..."
- while ((sock |& getline) > 0) {
- print;
- if ($0 ~ /^\s*$/) {
- print "connection closed";
- break;
- }
- # GET以外はしらない
- if ( $1 == "GET") {
- first = 1;
- print "type is GET";
- path = root $2;
- print "path is" path;
- while ((getline < path) > 0) {
- if (first) {
- printf "HTTP/1.1 200 OK\r\n\r\n" |& sock;
- }
- print |& sock;
- first = 0;
- }
- close (path);
- if (first) {
- printf "HTTP/1.1 404 Not Found\r\n\r\n" |& sock;
- }
- }
- }
- close(sock);
- }
- print |& sock;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement