Skip to content

Commit

Permalink
Add Java extension to do the same
Browse files Browse the repository at this point in the history
Co-authored-by: Charles Nutter <headius@headius.com>
  • Loading branch information
nateberkopec and headius committed Oct 7, 2019
1 parent 6dbdee2 commit 37eeb06
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ext/puma_http11/org/jruby/puma/Http11.java
Expand Up @@ -87,7 +87,9 @@ public void call(Object data, int field, int flen, int value, int vlen) {
validateMaxLength(flen, MAX_FIELD_NAME_LENGTH, MAX_FIELD_NAME_LENGTH_ERR);
validateMaxLength(vlen, MAX_FIELD_VALUE_LENGTH, MAX_FIELD_VALUE_LENGTH_ERR);

ByteList b = new ByteList(Http11.this.hp.parser.buffer,field,flen);
ByteList buffer = Http11.this.hp.parser.buffer;

ByteList b = new ByteList(buffer,field,flen);
for(int i = 0,j = b.length();i<j;i++) {
if((b.get(i) & 0xFF) == '-') {
b.set(i, (byte)'_');
Expand All @@ -105,7 +107,9 @@ public void call(Object data, int field, int flen, int value, int vlen) {
f.cat(b);
}

b = new ByteList(Http11.this.hp.parser.buffer, value, vlen);
while (vlen > 0 && Character.isWhitespace(buffer.get(value + vlen - 1))) vlen--;

b = new ByteList(buffer, value, vlen);
v = req.op_aref(req.getRuntime().getCurrentContext(), f);
if (v.isNil()) {
req.op_aset(req.getRuntime().getCurrentContext(), f, RubyString.newString(runtime, b));
Expand Down

0 comments on commit 37eeb06

Please sign in to comment.