@@ -1944,49 +1944,51 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server
1944
1944
php_cli_server_content_sender_ctor (& client -> content_sender );
1945
1945
client -> content_sender_initialized = 1 ;
1946
1946
1947
- escaped_request_uri = php_escape_html_entities_ex ((const unsigned char * ) client -> request .request_uri , client -> request .request_uri_len , 0 , ENT_QUOTES , NULL , /* double_encode */ 0 , /* quiet */ 0 );
1947
+ if (client -> request .request_method != PHP_HTTP_HEAD ) {
1948
+ escaped_request_uri = php_escape_html_entities_ex ((const unsigned char * ) client -> request .request_uri , client -> request .request_uri_len , 0 , ENT_QUOTES , NULL , /* double_encode */ 0 , /* quiet */ 0 );
1948
1949
1949
- {
1950
- static const char prologue_template [] = "<!doctype html><html><head><title>%d %s</title>" ;
1951
- php_cli_server_chunk * chunk = php_cli_server_chunk_heap_new_self_contained (strlen (prologue_template ) + 3 + strlen (status_string ) + 1 );
1952
- if (!chunk ) {
1953
- goto fail ;
1950
+ {
1951
+ static const char prologue_template [] = "<!doctype html><html><head><title>%d %s</title>" ;
1952
+ php_cli_server_chunk * chunk = php_cli_server_chunk_heap_new_self_contained (strlen (prologue_template ) + 3 + strlen (status_string ) + 1 );
1953
+ if (!chunk ) {
1954
+ goto fail ;
1955
+ }
1956
+ snprintf (chunk -> data .heap .p , chunk -> data .heap .len , prologue_template , status , status_string );
1957
+ chunk -> data .heap .len = strlen (chunk -> data .heap .p );
1958
+ php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
1954
1959
}
1955
- snprintf (chunk -> data .heap .p , chunk -> data .heap .len , prologue_template , status , status_string );
1956
- chunk -> data .heap .len = strlen (chunk -> data .heap .p );
1957
- php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
1958
- }
1959
- {
1960
- php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new (php_cli_server_css , sizeof (php_cli_server_css ) - 1 );
1961
- if (!chunk ) {
1962
- goto fail ;
1960
+ {
1961
+ php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new (php_cli_server_css , sizeof (php_cli_server_css ) - 1 );
1962
+ if (!chunk ) {
1963
+ goto fail ;
1964
+ }
1965
+ php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
1963
1966
}
1964
- php_cli_server_buffer_append ( & client -> content_sender . buffer , chunk );
1965
- }
1966
- {
1967
- static const char template [] = "</head><body>" ;
1968
- php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new ( template , sizeof ( template ) - 1 ) ;
1969
- if (! chunk ) {
1970
- goto fail ;
1967
+ {
1968
+ static const char template [] = "</head><body>" ;
1969
+ php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new ( template , sizeof ( template ) - 1 );
1970
+ if (! chunk ) {
1971
+ goto fail ;
1972
+ }
1973
+ php_cli_server_buffer_append ( & client -> content_sender . buffer , chunk ) ;
1971
1974
}
1972
- php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
1973
- }
1974
- {
1975
- 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 );
1976
- if (!chunk ) {
1977
- goto fail ;
1975
+ {
1976
+ 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 );
1977
+ if (!chunk ) {
1978
+ goto fail ;
1979
+ }
1980
+ snprintf (chunk -> data .heap .p , chunk -> data .heap .len , content_template , status_string , ZSTR_VAL (escaped_request_uri ));
1981
+ chunk -> data .heap .len = strlen (chunk -> data .heap .p );
1982
+ php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
1978
1983
}
1979
- snprintf (chunk -> data .heap .p , chunk -> data .heap .len , content_template , status_string , ZSTR_VAL (escaped_request_uri ));
1980
- chunk -> data .heap .len = strlen (chunk -> data .heap .p );
1981
- php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
1982
- }
1983
- {
1984
- static const char epilogue_template [] = "</body></html>" ;
1985
- php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new (epilogue_template , sizeof (epilogue_template ) - 1 );
1986
- if (!chunk ) {
1987
- goto fail ;
1984
+ {
1985
+ static const char epilogue_template [] = "</body></html>" ;
1986
+ php_cli_server_chunk * chunk = php_cli_server_chunk_immortal_new (epilogue_template , sizeof (epilogue_template ) - 1 );
1987
+ if (!chunk ) {
1988
+ goto fail ;
1989
+ }
1990
+ php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
1988
1991
}
1989
- php_cli_server_buffer_append (& client -> content_sender .buffer , chunk );
1990
1992
}
1991
1993
1992
1994
{
@@ -2017,14 +2019,18 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server
2017
2019
if (errstr ) {
2018
2020
pefree (errstr , 1 );
2019
2021
}
2020
- zend_string_free (escaped_request_uri );
2022
+ if (escaped_request_uri ) {
2023
+ zend_string_free (escaped_request_uri );
2024
+ }
2021
2025
return SUCCESS ;
2022
2026
2023
2027
fail :
2024
2028
if (errstr ) {
2025
2029
pefree (errstr , 1 );
2026
2030
}
2027
- zend_string_free (escaped_request_uri );
2031
+ if (escaped_request_uri ) {
2032
+ zend_string_free (escaped_request_uri );
2033
+ }
2028
2034
return FAILURE ;
2029
2035
} /* }}} */
2030
2036
@@ -2080,7 +2086,9 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv
2080
2086
2081
2087
php_cli_server_content_sender_ctor (& client -> content_sender );
2082
2088
client -> content_sender_initialized = 1 ;
2083
- client -> file_fd = fd ;
2089
+ if (client -> request .request_method != PHP_HTTP_HEAD ) {
2090
+ client -> file_fd = fd ;
2091
+ }
2084
2092
2085
2093
{
2086
2094
php_cli_server_chunk * chunk ;
0 commit comments