Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BEA15D1FC for ; Tue, 19 Jun 2012 05:26:51 +0000 (UTC) Received: (qmail 68556 invoked by uid 500); 19 Jun 2012 05:26:51 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 68397 invoked by uid 500); 19 Jun 2012 05:26:50 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 68373 invoked by uid 99); 19 Jun 2012 05:26:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Jun 2012 05:26: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: domain of ohaya@cox.net designates 68.230.241.214 as permitted sender) Received: from [68.230.241.214] (HELO eastrmfepo102.cox.net) (68.230.241.214) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Jun 2012 05:26:41 +0000 Received: from eastrmimpo306.cox.net ([68.230.241.238]) by eastrmfepo102.cox.net (InterMail vM.8.01.04.00 201-2260-137-20101110) with ESMTP id <20120619052620.BPFX26743.eastrmfepo102.cox.net@eastrmimpo306.cox.net> for ; Tue, 19 Jun 2012 01:26:20 -0400 Received: from eastrmwml304 ([172.18.18.217]) by eastrmimpo306.cox.net with bizsmtp id Q5SL1j0014h0NJL025SLLD; Tue, 19 Jun 2012 01:26:20 -0400 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020202.4FE00D7C.0016,ss=1,re=0.000,fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=1.1 cv=dNOJEUGZcFs5STy3k3rINHH9Rbwl7Iu0A7suO5q4evY= c=1 sm=1 a=Xml4jkKJQiAA:10 a=G8Uczd0VNMoA:10 a=X0LLrcwhTTAA:10 a=IkcTkHD0fZMA:10 a=TRy/vagDvAN6zvr8h90PzQ==:17 a=kviXuzpPAAAA:8 a=QeebE4tfmu_8gozG-GoA:9 a=QEXdDO2ut3YA:10 a=4vB-4DCPJfMA:10 a=TRy/vagDvAN6zvr8h90PzQ==:117 X-CM-Score: 0.00 Authentication-Results: cox.net; none Received: from 72.192.248.102 by webmail.east.cox.net; Tue, 19 Jun 2012 1:26:19 -0400 Message-ID: <20120619012620.4LP6T.140717.imail@eastrmwml304> Date: Tue, 19 Jun 2012 1:26:20 -0400 From: To: modules-dev@httpd.apache.org Subject: Re: How to *add* a cookie in module? In-Reply-To: <20120619010703.0AP5D.140669.imail@eastrmwml304> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) Sensitivity: Normal ---- ohaya@cox.net wrote: > > ---- ohaya@cox.net wrote: > > Hi, > > > > This is a followup to an earlier post/question, "How to access client certificate PEM and incoming request headers in a module?". > > > > As before, I'm starting with mod_headers.c, and then tweaking it, partly experimenting with modules, and partly for a project that I'm working on (eventually). > > > > What I'm trying to do now is: > > > > - I have a test Tomcat instance that is being proxied by Apache, with a small JSP that just dumps the HTTP headers > > - The Apache has my modified mod_headers. > > > > I now need to add ("inject") an additional cookie to the incoming request so that when the JSP dumps the headers, it'll show whatever cookies originally existed, plus the one that my modified mod_headers module added. > > > > As before, I'm adding my code to the beginning of "ap_headers_insert_output_filter()" in mod_headers.c: > > > > printf("\n\nIn ap_headers_insert_output_filter: About to call FIRST dump_request...\n"); > > dump_request(r); > > printf("In ap_headers_insert_output_filter: Returned from calling FIRST dump_request...\n"); > > > > printf("\n\nIn ap_headers_insert_output_filter: About to call apr_table_addn() to add 'Cookie' to r->headers_in\n"); > > apr_table_addn(r->headers_in, "Cookie", "MyCookie=AAAAAAAAAAAAAAAABBBBBBBBBBB"); > > printf("In ap_headers_insert_output_filter: Returned from calling apr_table_addn()...\n"); > > > > printf("\n\nIn ap_headers_insert_output_filter: About to call ap_headers_fixup()...\n"); > > ap_headers_fixup(r); > > printf("In ap_headers_insert_output_filter: Returned from calling ap_headers_fixup()...\n"); > > > > printf("\n\nIn ap_headers_insert_output_filter: About to call SECOND dump_request()...\n"); > > dump_request(r); > > printf("In ap_headers_insert_output_filter: Returned from calling SECOND dump_request()...\n"); > > > > .I'm running Apache in single process mode, so I can see the printf output, and for that first call to dump_request(), I can see a "Cookie" header with a JSESSION cookie, and then in the second call to dump_request, I can see a "Cookie" header, but it has only my "MyCookie" cookie. In other words, it looks like when the: > > > > apr_table_addn(r->headers_in, "Cookie", "MyCookie=AAAAAAAAAAAAAAAABBBBBBBBBBB"); > > > > was executed, it overwrote the "Cookie" header in the r->headers_in table? > > > > Can anyone tell me how I can *add* a cookie in my module? > > > > Thanks, > > Jim > > > > P.S. BTW, by the time the headers are displayed by the JSP on the proxied Tomcat, it shows ONLY the JSESSIONID cookie, i.e., it doesn't look like the MyCookie cookie got passed to Tomcat? > > > Hi, > > I think that I found one way to fix this. Instead of: > > apr_table_addn(r->headers_in, "Cookie", "MyCookie=AAAAAAAAAAAAAAAABBBBBBBBBBB"); > > I did: > > apr_table_mergen(r->headers_in, "Cookie", "MyCookie=AAAAAAAAAAAAAAAABBBBBBBBBBB"); > > and I now see the cookie that I added, both in the dump_request() output and in the JSP output. > > Jim Hi, I spoke too soon :(.... The apr_table_mergen puts a comma (",") in between each cookie name/value pair, rather than a semicolon (";"). So, does anyone know how I can accomplish the merge of the cookie headers, but with semicolons in between the name/value pairs? Jim