From 6ac46bfadaf61d89149e215ad6dcff76ee1a90ae Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 3 Sep 2014 17:27:06 +0000 Subject: http_common: correctly handle empty header values --- http_common.rl | 2 +- test/http.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/http_common.rl b/http_common.rl index a0fdd5a..4df7f42 100644 --- a/http_common.rl +++ b/http_common.rl @@ -10,7 +10,7 @@ eor = LWS*'\r'LF; CTL = (cntrl | 127); header_name = [a-zA-Z0-9\-]+; - header_value = (any -- (LWS|CTL))(any -- CTL)*; + header_value = (any -- CTL)*; sep = (LWS*)|(eor LWS+); b64_val = ([a-zA-Z0-9/+]{22}) > { http->_p.tmp_tip = to_u16(fpc - buf); diff --git a/test/http.rb b/test/http.rb index e23bddf..892e2db 100644 --- a/test/http.rb +++ b/test/http.rb @@ -38,6 +38,20 @@ class TestHTTP < Test::Unit::TestCase assert status.success?, status.inspect end + # neon does this + def test_empty_request_value + @client.write("GET / HTTP/1.1\r\n" \ + "Keep-Alive: \r\nConnection: TE,Keep-Alive\r\n\r\n") + buf = @client.readpartial(12345) + assert_match(%r{\AHTTP/1\.1 200 OK}, buf) + + # ensure persistent connections work + @client.write("GET / HTTP/1.1\r\n" \ + "Missing-Space:\r\n\r\n") + buf = @client.readpartial(12345) + assert_match(%r{\AHTTP/1\.1 200 OK}, buf) + end + def test_slash_for_mogadm_check Net::HTTP.start(@host, @port) do |http| [ Net::HTTP::Get, Net::HTTP::Head ].each do |meth| -- cgit v1.2.3-24-ge0c7