You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: main.js
+19-10Lines changed: 19 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ function runPHP(req, response, next, phpdir){
21
21
elsepathinfo=parts.pathname;
22
22
23
23
varenv={
24
+
SERVER_SIGNATURE: "NodeJS server at localhost",
24
25
PATH_INFO: pathinfo,//The extra path information, as given in the requested URL. In fact, scripts can be accessed by their virtual path, followed by extra information at the end of this path. The extra information is sent in PATH_INFO.
25
26
PATH_TRANSLATED: "",//The virtual-to-real mapped version of PATH_INFO.
26
27
SCRIPT_NAME: parts.pathname,//The virtual path of the script being executed.
@@ -31,8 +32,8 @@ function runPHP(req, response, next, phpdir){
31
32
SCRIPT_URL: req.url,
32
33
REQUEST_URI: req.url,//The original request URI sent by the client.
33
34
REQUEST_METHOD: req.method,//The method used by the current request; usually set to GET or POST.
34
-
QUERY_STRING: parts.query,//The information which follows the ? character in the requested URL.
35
-
CONTENT_TYPE: "application/x-www-form-urlencoded",//The MIME type of the request body; set only for POST or PUT requests.
35
+
QUERY_STRING: parts.query||"",//The information which follows the ? character in the requested URL.
36
+
CONTENT_TYPE: req.get("Content-type"),//"multipart/form-data", //"application/x-www-form-urlencoded", //The MIME type of the request body; set only for POST or PUT requests.
36
37
CONTENT_LENGTH: req.rawBody.length||0,//The length in bytes of the request body; set only for POST or PUT requests.
37
38
AUTH_TYPE: "",//The authentication type if the client has authenticated itself to access the script.
38
39
AUTH_USER: "",
@@ -59,7 +60,7 @@ function runPHP(req, response, next, phpdir){
59
60
60
61
//console.log(env);
61
62
//console.log("ALL: "+env.ALL_HTTP);
62
-
console.log("GET: "+file);
63
+
//console.log("GET: "+file);
63
64
//console.log("RAW BODY: "+req.rawBody);
64
65
65
66
if(/.*?\.php$/.test(file)){
@@ -70,7 +71,8 @@ function runPHP(req, response, next, phpdir){
70
71
});
71
72
72
73
//php.stdin.resume();
73
-
php.stdin.write(req.rawBody+"\n");
74
+
//console.log(req.rawBody);
75
+
php.stdin.write(req.rawBody);
74
76
php.stdin.end();
75
77
76
78
php.stdout.on("data",function(data){
@@ -93,7 +95,7 @@ function runPHP(req, response, next, phpdir){
93
95
varm=lines[line].split(": ");
94
96
if(m[0]==="")break;
95
97
96
-
//console.log("HEADER: "+m[0]+": "+m[1]);
98
+
console.log("HEADER: "+m[0]+": "+m[1]);
97
99
if(m[0]=="Status"){
98
100
response.statusCode=parseInt(m[1]);
99
101
}
@@ -102,12 +104,13 @@ function runPHP(req, response, next, phpdir){
102
104
}
103
105
line++;
104
106
}while(lines[line]!=="");
107
+
105
108
html=lines.splice(line+1).join("\n");
106
109
}else{
107
110
html=res;
108
111
}
109
112
//console.log("STATUS: "+response.statusCode);
110
-
113
+
//console.log(html);
111
114
response.send(html,response.statusCode);
112
115
response.end();
113
116
});
@@ -121,13 +124,19 @@ function runPHP(req, response, next, phpdir){
0 commit comments