about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-09-03 17:27:06 +0000
committerEric Wong <e@80x24.org>2014-09-07 00:39:38 +0000
commitcc46352c76193a2f1732a1f64761eea8b7581e60 (patch)
treea0832ae13ed4bfda6373ea99697ff32ad7529d24
parent5087825f3fd0ad59ce7afedaaaaa17d16196e1f6 (diff)
downloadcmogstored-cc46352c76193a2f1732a1f64761eea8b7581e60.tar.gz
The PHP PECL MogileFS extension uses neon to handle WebDAV operations,
and neon seems to send (valid but unfortunate) headers with empty
string values:

ref: http://svn.webdav.org/repos/projects/neon/trunk/src/ne_request.c

    else if (!sess->is_http11 && !sess->any_proxy_http) {
        ne_buffer_czappend(req->headers,
                           "Keep-Alive: " EOL
                          "Connection: TE, Keep-Alive" EOL);
    }
    else if (!req->session->is_http11 && !sess->any_proxy_http) {
        ne_buffer_czappend(req->headers,
                           "Keep-Alive: " EOL
                           "Proxy-Connection: Keep-Alive" EOL
                           "Connection: TE" EOL);
    }

Thanks to Patrice Damezin at Skyrock.com for reporting
the issue.
-rw-r--r--http_common.rl2
-rw-r--r--test/http.rb14
2 files changed, 15 insertions, 1 deletions
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|