ftinx / webserv

http/1.1 multiplexing webserver
0 stars 0 forks source link

[CGI] php-cgi 추가 #282

Closed yechoi42 closed 3 years ago

hochan222 commented 3 years ago

PHP CGI는 비표준 SCRIPT_FILENAME에 의존합니다 .

hochan222 commented 3 years ago
hochan222 commented 3 years ago

image

php-mac/lib/php/build/run-tests.php

hochan222 commented 3 years ago

https://aprelium.com/data/doc/2/abyssws-linux-doc-html/cgivars.html

hochan222 commented 3 years ago

    /*
    ** cgi
    */
    map["AUTH_TYPE"] = ""; //auth 인증 type ex=> cookie
    map["CONTENT_LENGTH"] = "";
    map["CONTENT_TYPE"] = "text/html";
    map["GATEWAY_INTERFACE"] = "CGI/1.1";
    map["PATH_INFO"] = "/directory/youpi.php";                  // 기본 cgi 필수요소
    map["PATH_TRANSLATED"] = "/Users/holee/Desktop/test/Webserv/YoupiBanane/youpi.php"; // 기본 cgi 필수요소
    map["QUERY_STRING"] = "";
    map["REMOTE_ADDR"] = "127.0.0.1";
    map["REMOTE_IDENT"] = "";
    map["REMOTE_USER"] = "";
    map["REQUEST_METHOD"] = "POST";                 // 기본 cgi 필수요소
    map["REQUEST_URI"] = "/directory/youpi.php";
    map["SCRIPT_NAME"] = "/Users/holee/Desktop/test/Webserv/YoupiBanane/youpi.php";
    map["SERVER_NAME"] = "first_server";
    map["SERVER_PORT"] = "8080";
    map["SERVER_PROTOCOL"] = "HTTP/1.1";        // 기본 cgi 필수요소
    map["SERVER_SOFTWARE"] = this->m_server_name;

    /* cgi */
    map["HTTP_X_SECRET_HEADER_FOR_TEST"] = '1';             // 기본 cgi 필수요소

    /* php */
    map["REDIRECT_STATUS"] = "200";
    map["SCRIPT_FILENAME"] = "/Users/holee/Desktop/test/Webserv/YoupiBanane/youpi.php";
hochan222 commented 3 years ago
<?php 
    print "Status: 200 OK\r\n";
    print "Content-Type: text/html; charset=utf-8\r\n\r\n";
    phpinfo(INFO_VARIABLES); 
?>

youpi.php