Bug 62955 - HEAD request via http/2 fail if GCI script do not return body part
Summary: HEAD request via http/2 fail if GCI script do not return body part
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_http2 (show other bugs)
Version: 2.4.34
Hardware: PC Linux
: P2 minor (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-27 11:36 UTC by vlado
Modified: 2019-03-24 17:15 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vlado 2018-11-27 11:36:36 UTC
When perform http HEAD request against php CGI script, I receive PROTOCOL_ERROR in case http/2 is used:

vlado@vladopc:~$ curl --http1.1 --head https://www.testurko.com/test/i.php
HTTP/1.1 200 OK
Date: Tue, 27 Nov 2018 11:15:13 GMT
Server: Apache
Upgrade: h2
Connection: Upgrade
Content-Type: text/html

vlado@vladopc:~$ curl --http2 --head https://www.testurko.com/test/i.php
curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

Further investigation lead me to the way php respond to HEAD request: it sends back only the header w/o the body part.
So I tried to reproduce this behavior with a simple perl script:
#!/usr/bin/perl
print "Content-Type: text/html\n\n";

print "<html> <head>\n";
print "<title>Hello, world!</title>";
print "</head>\n";
print "<body>\n";
print "<h1>Hello, world!</h1>\n";
print "</body> </html>\n";

And both HEAD and GET requests work well via http/1.1 and http/2 until I commented out the body part. 
Then the behavior become exactly the same as above:

# GET request:
vlado@vladopc:~$ curl --http2 https://www.testurko.com/test/i.pl

# HEAD requests:
vlado@vladopc:~$ curl --http2 --head https://www.testurko.com/test/i.pl
curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

vlado@vladopc:~$ curl --http1.1 --head https://www.testurko.com/test/i.pl
HTTP/1.1 200 OK
Date: Tue, 27 Nov 2018 11:23:07 GMT
Server: Apache
Upgrade: h2
Connection: Upgrade
Content-Type: text/html

Further attempts to investigate the problem lead me to Output filters: If I set any kind of output filter, the problem disappear. 
For example I tried both SetOutputFilter and AddOutputFilterByType in .htaccess with INCLUDES and DEFLATE filters and no matter what kind of filter is applied, the HEAD request via http/2 works.
Comment 1 steve anders 2018-11-28 07:11:24 UTC
perhaps this will help

<a href="https://games.lol/android/">66 unblocked games 66 at school</a>
Comment 2 Christophe JAILLET 2019-03-24 16:58:49 UTC
(RE-OPEN to revert some spam changes. Spam messages are still there unfortunately)
Comment 3 vlado 2019-03-24 17:15:30 UTC
Actually the issue was resolved in https://github.com/icing/mod_h2/issues/167
and is 2.4 branch waiting for the next release.