From 800cfeeac366e1d9e473d28f81d1e22f9db1d075 Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Ruiz Date: Fri, 6 Nov 2015 17:18:30 +0100 Subject: [PATCH] ext/puma_http11: handle duplicate headers as per RFC for Java ext The parser stores headers in a Ruby hash table so that when a header is found twice its value replaces the old one. As per RFC[1] this is not correct, since duplicated headers should all be considered. In particular, they are semantically equivalent to a single header with comma separated values. In this case, we follow existing practice of joining values with a comma and a single space character. [1] See RFC2616 section 4.2: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 --- ext/puma_http11/org/jruby/puma/Http11.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ext/puma_http11/org/jruby/puma/Http11.java b/ext/puma_http11/org/jruby/puma/Http11.java index 34fc6c7e..35355433 100644 --- a/ext/puma_http11/org/jruby/puma/Http11.java +++ b/ext/puma_http11/org/jruby/puma/Http11.java @@ -82,11 +82,11 @@ public class Http11 extends RubyObject { private Http11Parser.FieldCB http_field = new Http11Parser.FieldCB() { public void call(Object data, int field, int flen, int value, int vlen) { RubyHash req = (RubyHash)data; - RubyString v,f; + RubyString f; + IRubyObject v; validateMaxLength(flen, MAX_FIELD_NAME_LENGTH, MAX_FIELD_NAME_LENGTH_ERR); validateMaxLength(vlen, MAX_FIELD_VALUE_LENGTH, MAX_FIELD_VALUE_LENGTH_ERR); - v = RubyString.newString(runtime, new ByteList(Http11.this.hp.parser.buffer,value,vlen)); ByteList b = new ByteList(Http11.this.hp.parser.buffer,field,flen); for(int i = 0,j = b.length();i