Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 975861029C for ; Mon, 20 Jan 2014 21:47:33 +0000 (UTC) Received: (qmail 98115 invoked by uid 500); 20 Jan 2014 21:45:24 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 97669 invoked by uid 500); 20 Jan 2014 21:45:11 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 88422 invoked by uid 99); 20 Jan 2014 21:38:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jan 2014 21:38:50 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [209.85.192.174] (HELO mail-pd0-f174.google.com) (209.85.192.174) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jan 2014 21:38:42 +0000 Received: by mail-pd0-f174.google.com with SMTP id z10so2045326pdj.5 for ; Mon, 20 Jan 2014 13:38:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:content-type:subject:message-id:date :to:mime-version; bh=uAhi5rcGBisBCTnSQib7mT3c5Z2QDd92t7vk2p3isPg=; b=I9hrhOGUND5oZK87UX9EOWn7h/Yfr35Hd5/d9Z+0CMIRsu1xRt1FKyWNL7kb/lQqrv LnHVqC258pJq/fNayUYEUFH4KUawTRe/lM0cgKXQ43mGJig89FC94aF1r9hTupTIHrLP U3yfeEE9siDvamfIqlhsMa8KPn/cjqday1ncLkGaknEPUSyZdgvzAxnwoI1vtqEHX5EN SH4DYgrv/Q6wGJ8AXKb84H0y50ADulELInu5Mj8cDxmcBQbttNFLfFVfkuQLcyoM3NsJ ZqhTXtu7DAGtkdDx/SVGxOG2qe9JKm3vMCuM0nMJgorCc9KMNDy+7Pe0jD/j1MiBpg5I yEqg== X-Gm-Message-State: ALoCoQmj0+MJCpSZqCCgslVntEL907qS+XZ5LnyN5xeEwis5iHvJF6+MLbTbfFQoAilJOuD4HTca X-Received: by 10.66.4.130 with SMTP id k2mr20800049pak.95.1390253900398; Mon, 20 Jan 2014 13:38:20 -0800 (PST) Received: from [10.0.1.22] (c-24-16-133-248.hsd1.wa.comcast.net. [24.16.133.248]) by mx.google.com with ESMTPSA id xs1sm11648286pac.7.2014.01.20.13.38.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 13:38:16 -0800 (PST) Sender: Jeremy Boynes From: Jeremy Boynes Content-Type: multipart/signed; boundary="Apple-Mail=_BFB05A71-9B47-46F0-9F93-2B85FF4BA6F1"; protocol="application/pgp-signature"; micalg=pgp-sha512 Subject: Using HttpParser for Cookie header? Message-Id: Date: Mon, 20 Jan 2014 13:38:13 -0800 To: Tomcat Developers List Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) X-Mailer: Apple Mail (2.1827) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail=_BFB05A71-9B47-46F0-9F93-2B85FF4BA6F1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 I started to look at using HttpParser for the Cookie header but there = are some differences in the way it works compared to the existing parser = in Cookies that I wanted to check direction before getting too far in. The area I=92m concerned about is the need to copy the bytes in order to = parse the header. The Cookies parser relies heavily on MessageBytes and = avoids copying to a String as far as possible. HttpParser, however, = operates on a StringReader which requires converting to a String before = parsing. After digging into the usage of Cookies I think there are only two = places that read them: 1) Request#getCookies(), which needs to copy to Strings anyway in order = to create the Cookie instances it returns 2) CoyoteAdapter#parseSessionCookiesId(), which parses the header and = compares names as MessageBytes, only allocating a String for the value = if the session cookie is found It=92s this second one that has me concerned about switching to = HttpParser as this gets called for every request. If we switch then = there is going to be allocation and copying of the header that we = currently don=92t do.=20 Having said that, the current parse relies heavily on the assumption = that the header is US-ASCII encoded and that it is only dealing with = 7-bit characters (it freely casts bytes to chars). The cookie change = proposal has us supporting UTF-8 as specified by HTML5 which means a = more robust decoder will be needed and the copy may not be avoidable. My plan here is to KISS and implement a parser similar to the others in = HttpParser assuming the header has already been decoded so it can just = deal with the chars. Then if we notice any performance degradation we = can focus on improving HttpParser which will have the benefit of working = for the other header parsers as well. I=92ll implement this alongside = the existing code (actually, in the parser package) to make it easier to = do an A-B comparison. There would likely be some follow-on changes from such a change. Cookies = and ServerCookie are recyclable objects associated with the request. By = moving away from MessageBytes these could be replaced by basic String = values and may not be needed e.g. Request already caches the array of = Cookie values returned from getCookies() and that could be now populated = directly from the parse. These classes may end up going away. Thanks Jeremy --Apple-Mail=_BFB05A71-9B47-46F0-9F93-2B85FF4BA6F1 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQEcBAEBCgAGBQJS3ZdFAAoJEKVK0I6noCM8egUIAIOJyfM3UJUgllSRlbdJsHi/ h5qbrccFMA9JRqVX1oWeqZFlDtkxqKMvhQvR4ICqwNdOSOreo+d5QUjdRhpXKxzr tf+GQKa2lXpg1k+laH6NhlrkhGl4MOUa8duWyMwCFrDBFPW/OdJSdeL/HhjdBs8e OpAHI1icnDTBWp7rKDOZyprZOAzDJ1Mr5ickQti62YPcVwAdwmk0MWU6ARuV6q0S zLWJrpRlbGR2fnDBkTnhxtPmZiwuSAdova/E4Yq75ESy8VSdUjOd8LKeJgJ9Xd+m CygBSZ+J213xGn2WzSYMvJXYqDlkNBu3KAfa6KU3WUqp2iCUs7z0l/wGf7iDwmc= =YLDr -----END PGP SIGNATURE----- --Apple-Mail=_BFB05A71-9B47-46F0-9F93-2B85FF4BA6F1--