From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.mongrel.devel Subject: Re: [PATCH] join repeated headers with a comma Date: Sun, 9 Aug 2009 17:19:54 -0700 Message-ID: <20090810001954.GA18021@dcvr.yhbt.net> References: <20090810001022.GA17572@dcvr.yhbt.net> Reply-To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1249863605 31188 80.91.229.12 (10 Aug 2009 00:20:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 10 Aug 2009 00:20:05 +0000 (UTC) To: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Original-X-From: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Mon Aug 10 02:19:58 2009 Return-path: Envelope-to: gclrmd-mongrel-development@m.gmane.org Content-Disposition: inline In-Reply-To: <20090810001022.GA17572-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-BeenThere: mongrel-development-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: mongrel-development-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.mongrel.devel:151 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1MaIcI-0001cx-39 for gclrmd-mongrel-development@m.gmane.org; Mon, 10 Aug 2009 02:19:58 +0200 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 571411858120; Sun, 9 Aug 2009 20:19:57 -0400 (EDT) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id 69F3C1858111 for ; Sun, 9 Aug 2009 20:19:55 -0400 (EDT) Received: from localhost (user-118bg0q.cable.mindspring.com [66.133.192.26]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPSA id A7ECC1F7E0; Mon, 10 Aug 2009 00:19:54 +0000 (UTC) List-Post: > --- a/ext/http11/http11.c > +++ b/ext/http11/http11.c > @@ -182,6 +182,7 @@ void http_field(void *data, const char *field, size_t flen, const char *value, s > VALUE req = (VALUE)data; > VALUE v = Qnil; > VALUE f = Qnil; > + VALUE e = Qnil; > > VALIDATE_MAX_LENGTH(flen, FIELD_NAME); > VALIDATE_MAX_LENGTH(vlen, FIELD_VALUE); On second thought, we're doing the concatenation _after_ the length validation. I don't think this affects things much in practice since we already have an overall header size limit and anything capable of running Ruby/Mongrel shouldn't have to worry given about a few tens of kilobytes... > @@ -208,7 +209,13 @@ void http_field(void *data, const char *field, size_t flen, const char *value, s > /* fprintf(stderr, "UNKNOWN HEADER <%s>\n", RSTRING_PTR(f)); */ > } > > - rb_hash_aset(req, f, v); > + e = rb_hash_aref(req, f); > + if (e == Qnil) { > + rb_hash_aset(req, f, v); > + } else { > + rb_str_buf_cat(e, ",", 1); > + rb_str_buf_append(e, v); > + } > }