Received: (qmail 189 invoked by uid 2012); 11 Jun 1999 17:59:26 -0000 Message-Id: <19990611175926.188.qmail@hyperreal.org> Date: 11 Jun 1999 17:59:26 -0000 From: Diemo Shergowski Reply-To: mmmeier@bigfoot.de To: apbugs@hyperreal.org Subject: ap_table_add() doesn't seem to add but to replace values for the same key X-Send-Pr-Version: 3.2 >Number: 4571 >Category: apache-api >Synopsis: ap_table_add() doesn't seem to add but to replace values for the same key >Confidential: no >Severity: non-critical >Priority: medium >Responsible: apache >State: closed >Class: mistaken >Submitter-Id: apache >Arrival-Date: Fri Jun 11 11:00:03 PDT 1999 >Last-Modified: Mon Jun 21 12:28:14 PDT 1999 >Originator: mmmeier@bigfoot.de >Organization: >Release: 1.3.6 >Environment: Linux Kernel 2.2.6, gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release) >Description: the Apache API function ap_table_add() seems to replace values for the same key rather than adding a new entry with the same _key_ but a another value! Thus, a code fragment like the following doesn't workm the way I'd need it: for(i=0; i < max; i++) { ap_table_add(r->subprocess_env,"Key",Val[i].string);} What shows up using the printenv cgi script is the last added value (, prepended with REDIRECT_). I've tried using the ap_table_set() function with the same _key_ before the for-loop because similar hash implementations in other systmes required it, but it didn't work. >How-To-Repeat: My setup is a self-written (auth)module which uses ap_table_add() to set env vars in request_req->subprocess_env to pass them to an ErrorDocument: in the mod, ap_table_add() is called in a for-loop, after the for-loop HTT_INTERNAL_SERVER_ERROR is returned which starts a the "printenv" CGI-script, set using "ErrorDocument 500 /cgi-bin/printenv". >Fix: To me, it seems like ap_table_add() is broken. >Audit-Trail: State-Changed-From-To: open-closed State-Changed-By: coar State-Changed-When: Mon Jun 21 12:28:13 PDT 1999 State-Changed-Why: No, ap_table_add() adds a new key/value pair to the list. When the environment table is constructed for a CGI script or something similar, only one of those values can be used. How are you expecting to get multiple evariables with the same name but different values? If you step through the table in your code, after adding a list of values, you'll find that all of the key/value pairs are there -- but many things can only deal with a single one, and will end up taking either the first or the last depending upon implementation. Class-Changed-From-To: sw-bug-mistaken Class-Changed-By: coar Class-Changed-When: Mon Jun 21 12:28:13 PDT 1999 >Unformatted: [In order for any reply to be added to the PR database, you need] [to include in the Cc line and make sure the] [subject line starts with the report component and number, with ] [or without any 'Re:' prefixes (such as "general/1098:" or ] ["Re: general/1098:"). If the subject doesn't match this ] [pattern, your message will be misfiled and ignored. The ] ["apbugs" address is not added to the Cc line of messages from ] [the database automatically because of the potential for mail ] [loops. If you do not include this Cc, your reply may be ig- ] [nored unless you are responding to an explicit request from a ] [developer. Reply only with text; DO NOT SEND ATTACHMENTS! ]