]> granicus.if.org Git - php/commitdiff
Added mandatory Date: header to built-in webserver
authorSeeSchloss <see@seos.fr>
Thu, 21 Jan 2016 17:20:24 +0000 (17:20 +0000)
committerAnatol Belski <ab@php.net>
Thu, 2 Jun 2016 10:27:48 +0000 (12:27 +0200)
27 files changed:
sapi/cli/php_cli_server.c
sapi/cli/tests/bug43177.phpt
sapi/cli/tests/bug65066_100.phpt
sapi/cli/tests/bug65066_422.phpt
sapi/cli/tests/bug65066_511.phpt
sapi/cli/tests/bug65633.phpt
sapi/cli/tests/bug66606_2.phpt
sapi/cli/tests/bug66830.phpt
sapi/cli/tests/bug67429.phpt
sapi/cli/tests/bug68745.phpt
sapi/cli/tests/bug71005.phpt
sapi/cli/tests/php_cli_server_004.phpt
sapi/cli/tests/php_cli_server_005.phpt
sapi/cli/tests/php_cli_server_006.phpt
sapi/cli/tests/php_cli_server_007.phpt
sapi/cli/tests/php_cli_server_008.phpt
sapi/cli/tests/php_cli_server_009.phpt
sapi/cli/tests/php_cli_server_010.phpt
sapi/cli/tests/php_cli_server_012.phpt
sapi/cli/tests/php_cli_server_013.phpt
sapi/cli/tests/php_cli_server_014.phpt
sapi/cli/tests/php_cli_server_015.phpt
sapi/cli/tests/php_cli_server_017.phpt
sapi/cli/tests/php_cli_server_018.phpt
sapi/cli/tests/php_cli_server_019.phpt
sapi/cli/tests/php_cli_server_020.phpt
sapi/cli/tests/upload_2G.phpt

index f94ac747415921c82226fa06607bb5149e51ba30..e7c9f43cb4400805c1135273a6bfb652248ddb7d 100644 (file)
@@ -96,6 +96,7 @@
 #include "ext/standard/html.h"
 #include "ext/standard/url.h" /* for php_raw_url_decode() */
 #include "ext/standard/php_string.h" /* for php_dirname() */
+#include "ext/date/php_date.h" /* for php_format_date() */
 #include "php_network.h"
 
 #include "php_http_parser.h"
@@ -348,6 +349,13 @@ static void append_essential_headers(smart_str* buffer, php_cli_server_client *c
                        smart_str_appendl_ex(buffer, "\r\n", 2, persistent);
                }
        }
+       time_t t;
+       time(&t);
+       zend_string *dt = php_format_date("r", 1, t, 1);
+       smart_str_appendl_ex(buffer, "Date: ", 6, persistent);
+       smart_str_appends_ex(buffer, dt->val, persistent);
+       smart_str_appendl_ex(buffer, "\r\n", 2, persistent);
+
        smart_str_appendl_ex(buffer, "Connection: close\r\n", sizeof("Connection: close\r\n") - 1, persistent);
 } /* }}} */
 
index 23af545908d3ff0a406fc7d52801c1ce8ef38375..e475fb09b45663d973a103e284970613561bce94 100644 (file)
@@ -61,6 +61,7 @@ HEADER
 --EXPECTF--
 HTTP/1.1 200 OK
 Host: localhost
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: text/html; charset=UTF-8
@@ -68,18 +69,21 @@ Content-type: text/html; charset=UTF-8
 OK
 HTTP/1.0 500 Internal Server Error
 Host: localhost
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: text/html; charset=UTF-8
 
 HTTP/1.0 500 Internal Server Error
 Host: localhost
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: text/html; charset=UTF-8
 
 HTTP/1.0 500 Internal Server Error
 Host: localhost
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: text/html; charset=UTF-8
index 901ba188fd2011e668485b0e2905d92153b2e8ae..34381d8e96c57b7e5fa08b3c5f2042f73b0a4eec 100644 (file)
@@ -34,6 +34,7 @@ HEADER
 --EXPECTF--
 HTTP/1.1 100 Continue
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index 4e5d31c7a7f5954d8882fdce94b03eb89bc00495..f25ddfbca685c5acaeb1d5a222135d254d6742b1 100644 (file)
@@ -34,6 +34,7 @@ HEADER
 --EXPECTF--
 HTTP/1.1 422 Unknown Status Code
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index a0b4eae3931fb9e9811746b0e476a7f451d07976..27c9f9755a14e6682b39240640652d6058db03ce 100644 (file)
@@ -34,6 +34,7 @@ HEADER
 --EXPECTF--
 HTTP/1.1 511 Network Authentication Required
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index 456436b1f794f5519aafdb21bb002702a9e5e559..2e9f2796e8055f52563db3b6992ab1fc9b3c795b 100644 (file)
@@ -37,6 +37,7 @@ fclose($fp);
 ?>
 --EXPECTF--
 HTTP/1.1 200 OK
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: text/html; charset=UTF-8
index 9f539873e1fa025b1164e0d48ccb732438e587c8..c47b7736c0c1733fefd67515ebf82aac2ea85b37 100644 (file)
@@ -38,6 +38,7 @@ fclose($fp);
 --EXPECTF--    
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index 58c07e031ab7fb965ce42ec7b25c49ed5c7a843e..b21b33627ef1f4ba162d7d4e9ca80442e67b9529 100644 (file)
@@ -37,6 +37,7 @@ fclose($fp);
 --EXPECTF--
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: text/html; charset=UTF-8
index 856946b29dac81fd16771009b075d7a100f8ea3a..2ad4a27f07b6332682655d948fcec9ccc719c599 100644 (file)
@@ -38,11 +38,13 @@ HEADER
 ?>
 --EXPECTF--
 HTTP/1.1 308 Permanent Redirect
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: text/html; charset=UTF-8
 
 HTTP/1.1 426 Upgrade Required
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: text/html; charset=UTF-8
index 733d7d09006a8e5d839fd35892aea062b17da603..4cdfe0ae4e9412b62202662721c47ebbee26ed1c 100644 (file)
@@ -27,6 +27,7 @@ fclose($fp);
 ?>
 --EXPECTF--
 HTTP/1.1 200 OK
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: text/html; charset=UTF-8
index 3a60dcf42f56cf8a3006d51252edb19bc386c69f..f02f261fbf7f683e43f9a7b2d2296371d1633ad4 100644 (file)
@@ -39,6 +39,7 @@ HEADER
 --EXPECTF--    
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index 8b913f6596cba47d069ec2dff953bab36e214b45..5e3bbec18ff1f1bf31ba7b83ad566552f433d01a 100644 (file)
@@ -38,6 +38,7 @@ HEADER
 --EXPECTF--    
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index cdd0ae902fcaaf1fd6c90605bb9cfa8d23e95015..3f9078c8aeb4791cfcb75cef78d7e1300281d407 100644 (file)
@@ -50,6 +50,7 @@ HEADER
 --EXPECTF--    
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index ad6d6c9598b874335160a341043ecc50b8dd837b..c68f1e51b0812ef2d9c83701a8b9c4f505ae2336 100644 (file)
@@ -34,6 +34,7 @@ HEADER
 --EXPECTF--    
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index 6420ff5a41208b7827d0ba71e4c4d854a4c43c64..b588b9ee2ec9374120f1b5fae5be5fa7eb36814d 100644 (file)
@@ -34,6 +34,7 @@ HEADER
 --EXPECTF--    
 HTTP/1.1 401 Unauthorized
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 WWW-Authenticate: Digest realm="foo",qop="auth",nonce="XXXXX",opaque="acbd18db4cc2f85cedef654fccc4a4d8"
index 01f825a74614d59590bc91a4765dbc225ffa1ba9..58b2485db5362119e767a6f7ab3820522bec3667 100644 (file)
@@ -54,6 +54,7 @@ fclose($fp);
 --EXPECTF--
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
@@ -61,6 +62,7 @@ Content-type: text/html; charset=UTF-8
 string(8) "HTTP/1.1"
 HTTP/1.0 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index 7f3009b9bdc25d4ee15c8b9b26c01294dd5fdba6..d63c6abf28ebc13feb74fa72472e92a65a68d186 100644 (file)
@@ -78,6 +78,7 @@ fclose($fp);
 --EXPECTF--
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
@@ -85,6 +86,7 @@ Content-type: text/html; charset=UTF-8
 string(8) "/foo/bar"
 HTTP/1.0 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index ce3abeb5013c78716be8bb059dfa30e854c8ff89..fe8f1a98ca3919813adf33069fe9c8a1c32dc3dc 100644 (file)
@@ -55,6 +55,7 @@ fclose($fp);
 --EXPECTF--
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
@@ -65,6 +66,7 @@ string(8) "/foo/bar"
 string(7) "foo=bar"
 HTTP/1.0 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index 302540f7e67f4a020795b54a6bf6bb1b4e68a0d9..10b9cdbfe916f67f3bc823188ed6adc64417107c 100644 (file)
@@ -40,6 +40,7 @@ fclose($fp);
 --EXPECTF--
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index 3ea3ea9cadb0b64b6a0151f5e2df80658c4b8588..23269580fbc46418f89c81139904887332601a97 100644 (file)
@@ -83,6 +83,7 @@ fclose($fp);
 
 HTTP/1.1 404 Not Found
 Host: %s
+Date: %s
 Connection: close
 Content-Type: text/html; charset=UTF-8
 Content-Length: %d
@@ -91,6 +92,7 @@ Content-Length: %d
 </head><body><h1>Not Found</h1><p>The requested resource <code class="url">/</code> was not found on this server.</p></body></html>
 HTTP/1.1 404 Not Found
 Host: %s
+Date: %s
 Connection: close
 Content-Type: text/html; charset=UTF-8
 Content-Length: %d
@@ -99,6 +101,7 @@ Content-Length: %d
 </head><body><h1>Not Found</h1><p>The requested resource <code class="url">/main/style.css</code> was not found on this server.</p></body></html>
 HTTP/1.1 404 Not Found
 Host: %s
+Date: %s
 Connection: close
 Content-Type: text/html; charset=UTF-8
 Content-Length: %d
index 4f812e2f63533dbc842142c01bafdf0150f92a68..7c50a5e30a3d0547b3b15d660b0a268526b609b6 100644 (file)
@@ -65,6 +65,7 @@ fclose($fp);
 
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: %s
@@ -72,6 +73,7 @@ Content-type: %s
 done
 HTTP/1.1 404 Not Found
 Host: %s
+Date: %s
 Connection: close
 Content-Type: %s
 Content-Length: %d
index af0a3f65a80457986e72c5c1690f16779121809e..663268aea68965f32f1e713b3849d15a9cc36543 100644 (file)
@@ -41,6 +41,7 @@ fclose($fp);
 --EXPECTF--
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index 34e7d5e289ea0accd7b941020487661171cf9c19..28876dc52b4ebe525759450f0e85fcdb662d89fd 100644 (file)
@@ -37,6 +37,7 @@ fclose($fp);
 --EXPECTF--
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: text/html; charset=UTF-8
index 44e12929349da54971d0bab99cad0ed2f9f60bed..acfb0f2ce3ae1668fb6c69449a4ffaa15ec914dc 100644 (file)
@@ -37,6 +37,7 @@ fclose($fp);
 --EXPECTF--
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: %s
 Content-type: text/html; charset=UTF-8
index aeb7a9f89160954373995905ee6b7bf6c8b9bcc9..7be87a86c9e0b36f793552125a0eaaef5b817b2b 100644 (file)
@@ -41,6 +41,7 @@ fclose($fp);
 --EXPECTF--
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: %s
 Bar-Foo: Foo
index 4ed673d380e046ae520beefd6f3d8cd6f9c85cbc..766c6669118213a7cf276fcbf252ecd8b22773c3 100644 (file)
@@ -33,6 +33,7 @@ HEADER
 --EXPECTF--    
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8
index bd36ad6cda0667c681e23c7b7ff99ac7afc014ae..21dacb439aee0fc046f3034fd0d01f03654817be 100644 (file)
@@ -81,6 +81,7 @@ Test
 
 HTTP/1.1 200 OK
 Host: %s
+Date: %s
 Connection: close
 X-Powered-By: PHP/%s
 Content-type: text/html; charset=UTF-8