---- oh...@cox.net wrote: > > ---- oh...@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