File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<?php
22
33/**
4- * Node.php v0.3
4+ * Node.php v0.4
55 * (c) 2016 Jerzy Głowacki
66 * MIT License
77 */
@@ -122,7 +122,17 @@ function node_serve($path = "") {
122122 $ curl = curl_init ("http://127.0.0.1: " . NODE_PORT . "/ $ path " );
123123 curl_setopt ($ curl , CURLOPT_HEADER , 1 );
124124 curl_setopt ($ curl , CURLOPT_RETURNTRANSFER , 1 );
125- $ resp = curl_exec ($ curl );
125+ $ headers = array ();
126+ foreach (getallheaders () as $ key => $ value ) {
127+ $ headers [] = $ key . ": " . $ value ;
128+ }
129+ curl_setopt ($ curl , CURLOPT_HTTPHEADER , $ headers );
130+ curl_setopt ($ curl , CURLOPT_CUSTOMREQUEST , $ _SERVER ["REQUEST_METHOD " ]);
131+ if ($ _SERVER ["REQUEST_METHOD " ] === "POST " ) {
132+ curl_setopt ($ curl , CURLOPT_POST , 1 );
133+ curl_setopt ($ curl , CURLOPT_POSTFIELDS , http_build_query ($ _POST ));
134+ }
135+ $ resp = curl_exec ($ curl );
126136 if ($ resp === false ) {
127137 node_head ();
128138 echo "Error requesting $ path: " . curl_error ($ curl );
You can’t perform that action at this time.
0 commit comments