@@ -1980,49 +1980,51 @@ static zend_result php_cli_server_send_error_page(php_cli_server *server, php_cl
1980
1980
php_cli_server_content_sender_ctor (& client -> content_sender );
1981
1981
client -> content_sender_initialized = true;
1982
1982
1983
- escaped_request_uri = php_escape_html_entities_ex ((const unsigned char * ) ZSTR_VAL (client -> request .request_uri ), ZSTR_LEN (client -> request .request_uri ), 0 , ENT_QUOTES , NULL , /* double_encode */ 0 , /* quiet */ 0 );
1983
+ if (client -> request .request_method != PHP_HTTP_HEAD ) {
1984
+ escaped_request_uri = php_escape_html_entities_ex ((const unsigned char * ) ZSTR_VAL (client -> request .request_uri ), ZSTR_LEN (client -> request .request_uri ), 0 , ENT_QUOTES , NULL , /* double_encode */ 0 , /* quiet */ 0 );
1984
1985
1985
- {
1986
- static const char prologue_template [] = "<!doctype html><html><head><title>%d %s</title>" ;
1987
- php_cli_server_chunk * chunk = php_cli_server_chunk_heap_new_self_contained (strlen (prologue_template ) + 3 + strlen (status_string ) + 1 );
1988
- if (!chunk ) {
1989
- goto fail ;
1986
+ {
1987
+ static const char prologue_template [] = "<!doctype html><html><head><title>%d %s</title>" ;
1988
+ php_cli_server_chunk * chunk = php_cli_server_chunk_heap_new_self_contained (strlen (prologue_template ) + 3 + strlen (status_string ) + 1 );
1989
+ if (!chunk ) {
1990
+ goto fail ;
1991
+ }
1992
+ snprintf (chunk -> data .heap .p , chunk -> data .heap .len , prologue_template , status , status_string );
1993
+ chunk -> data .heap .len = strlen (chunk -> data .heap .p );
1994
+ php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
1990
1995
}
1991
- snprintf (chunk -> data .heap .p , chunk -> data .heap .len , prologue_template , status , status_string );
1992
- chunk -> data .heap .len = strlen (chunk -> data .heap .p );
1993
- php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
1994
- }
1995
- {
1996
- php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new (php_cli_server_css , sizeof (php_cli_server_css ) - 1 );
1997
- if (!chunk ) {
1998
- goto fail ;
1996
+ {
1997
+ php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new (php_cli_server_css , sizeof (php_cli_server_css ) - 1 );
1998
+ if (!chunk ) {
1999
+ goto fail ;
2000
+ }
2001
+ php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
1999
2002
}
2000
- php_cli_server_buffer_append ( & client -> content_sender . buffer , chunk );
2001
- }
2002
- {
2003
- static const char template [] = "</head><body>" ;
2004
- php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new ( template , sizeof ( template ) - 1 ) ;
2005
- if (! chunk ) {
2006
- goto fail ;
2003
+ {
2004
+ static const char template [] = "</head><body>" ;
2005
+ php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new ( template , sizeof ( template ) - 1 );
2006
+ if (! chunk ) {
2007
+ goto fail ;
2008
+ }
2009
+ php_cli_server_buffer_append ( & client -> content_sender . buffer , chunk ) ;
2007
2010
}
2008
- php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
2009
- }
2010
- {
2011
- php_cli_server_chunk * chunk = php_cli_server_chunk_heap_new_self_contained (strlen (content_template ) + ZSTR_LEN (escaped_request_uri ) + 3 + strlen (status_string ) + 1 );
2012
- if (!chunk ) {
2013
- goto fail ;
2011
+ {
2012
+ php_cli_server_chunk * chunk = php_cli_server_chunk_heap_new_self_contained (strlen (content_template ) + ZSTR_LEN (escaped_request_uri ) + 3 + strlen (status_string ) + 1 );
2013
+ if (!chunk ) {
2014
+ goto fail ;
2015
+ }
2016
+ snprintf (chunk -> data .heap .p , chunk -> data .heap .len , content_template , status_string , ZSTR_VAL (escaped_request_uri ));
2017
+ chunk -> data .heap .len = strlen (chunk -> data .heap .p );
2018
+ php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
2014
2019
}
2015
- snprintf (chunk -> data .heap .p , chunk -> data .heap .len , content_template , status_string , ZSTR_VAL (escaped_request_uri ));
2016
- chunk -> data .heap .len = strlen (chunk -> data .heap .p );
2017
- php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
2018
- }
2019
- {
2020
- static const char epilogue_template [] = "</body></html>" ;
2021
- php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new (epilogue_template , sizeof (epilogue_template ) - 1 );
2022
- if (!chunk ) {
2023
- goto fail ;
2020
+ {
2021
+ static const char epilogue_template [] = "</body></html>" ;
2022
+ php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new (epilogue_template , sizeof (epilogue_template ) - 1 );
2023
+ if (!chunk ) {
2024
+ goto fail ;
2025
+ }
2026
+ php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
2024
2027
}
2025
- php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
2026
2028
}
2027
2029
2028
2030
{
@@ -2053,14 +2055,18 @@ static zend_result php_cli_server_send_error_page(php_cli_server *server, php_cl
2053
2055
if (errstr ) {
2054
2056
pefree (errstr , 1 );
2055
2057
}
2056
- zend_string_free (escaped_request_uri );
2058
+ if (escaped_request_uri ) {
2059
+ zend_string_free (escaped_request_uri );
2060
+ }
2057
2061
return SUCCESS ;
2058
2062
2059
2063
fail :
2060
2064
if (errstr ) {
2061
2065
pefree (errstr , 1 );
2062
2066
}
2063
- zend_string_free (escaped_request_uri );
2067
+ if (escaped_request_uri ) {
2068
+ zend_string_free (escaped_request_uri );
2069
+ }
2064
2070
return FAILURE ;
2065
2071
} /* }}} */
2066
2072
@@ -2115,7 +2121,9 @@ static zend_result php_cli_server_begin_send_static(php_cli_server *server, php_
2115
2121
2116
2122
php_cli_server_content_sender_ctor (& client -> content_sender );
2117
2123
client -> content_sender_initialized = true;
2118
- client -> file_fd = fd ;
2124
+ if (client -> request .request_method != PHP_HTTP_HEAD ) {
2125
+ client -> file_fd = fd ;
2126
+ }
2119
2127
2120
2128
{
2121
2129
php_cli_server_chunk * chunk ;
0 commit comments