Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 42332 invoked from network); 11 Jan 2009 12:22:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Jan 2009 12:22:24 -0000 Received: (qmail 72567 invoked by uid 500); 11 Jan 2009 12:22:22 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 72507 invoked by uid 500); 11 Jan 2009 12:22:21 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 72494 invoked by uid 99); 11 Jan 2009 12:22:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jan 2009 04:22:21 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [64.233.170.186] (HELO rn-out-0910.google.com) (64.233.170.186) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jan 2009 12:22:13 +0000 Received: by rn-out-0910.google.com with SMTP id k40so6951850rnd.17 for ; Sun, 11 Jan 2009 04:21:50 -0800 (PST) Received: by 10.90.33.15 with SMTP id g15mr8491438agg.47.1231676510783; Sun, 11 Jan 2009 04:21:50 -0800 (PST) Received: by 10.90.114.16 with HTTP; Sun, 11 Jan 2009 04:21:50 -0800 (PST) Message-ID: Date: Sun, 11 Jan 2009 13:21:50 +0100 From: "Bertrand Mansion" Reply-To: bmansion@mamasam.net To: dev@httpd.apache.org Subject: mod_lua headers_out MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_269170_30733771.1231676510783" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_269170_30733771.1231676510783 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, My name is Bertrand Mansion, I live in Paris, France, I have been mostly programming in PHP for the last few years and I am very excited about mod_lua since I consider Lua is superior in many ways. I have followed the development of mod_wombat and noticed that you changed the way headers_in and headers_out are accessed, they were previously tables, now only headers_in can be accessed through a headers_in() method. I have written a method to have access to headers_out as well. I am not sure it is perfect since I haven't coded with Lua and apr C APIs before and many you thought already about something more clever. Anyway, with this patch, you can do: r:headers_out('Location', 'http://www.example.com') -- set the Location header r:headers_out('Location) -- return the current value for header Location r:headers_out('Location', nil) -- unset the Location header There might be other options I haven't implemented for example: r.headers_out['Location'] = 'http://www.example.com' -- like in previous versions of mod_wombat or r:headers_out{Location = 'http://www.example.com} -- but then it becomes harder to unset a header (?) or r.headers_out:set('Location', 'http://www.example.com') r.headers_out:get('Location') r.headers_out:unset('Location') HTH ----- Bertrand Mansion Mamasam ------=_Part_269170_30733771.1231676510783 Content-Type: text/plain; name=mod_lua_headers_out.diff.txt Content-Transfer-Encoding: base64 X-Attachment-Id: f_fptoa0tu0 Content-Disposition: attachment; filename=mod_lua_headers_out.diff.txt LS0tIGx1YV9yZXF1ZXN0LmMKKysrIChjbGlwYm9hcmQpCkBAIC00NDcsNiArNDQ3LDQxIEBACiAg ICAgcmV0dXJuIDE7CiB9CiAKK3N0YXRpYyBpbnQgcmVxX2hlYWRlcnNfb3V0KGx1YV9TdGF0ZSAq TCkKK3sKKyAgICBjb25zdCBjaGFyICprZXk7CisgICAgY29uc3QgY2hhciAqdmFsdWU7CisKKyAg ICByZXF1ZXN0X3JlYyAqciA9IGFwbF9jaGVja19yZXF1ZXN0X3JlYyhMLCAxKTsKKworICAgIGtl eSA9IGx1YUxfY2hlY2tzdHJpbmcoTCwgMik7CisKKyAgICBpZiAobHVhX2lzbm9uZShMLCAzKSA9 PSAxKSB7CisgICAgICAgIC8qIGdldHRpbmcgYSB2YWx1ZSBmcm9tIGhlYWRlcnNfb3V0ICovCisg ICAgICAgIHZhbHVlID0gYXByX3RhYmxlX2dldChyLT5oZWFkZXJzX291dCwga2V5KTsKKyAgICAg ICAgaWYgKHZhbHVlKSB7CisgICAgICAgICAgICBsdWFfcHVzaHN0cmluZyhMLCB2YWx1ZSk7Cisg ICAgICAgIH0KKyAgICAgICAgZWxzZSB7CisgICAgICAgICAgICBsdWFfcHVzaG5pbChMKTsKKyAg ICAgICAgfQorICAgIH0KKyAgICBlbHNlIHsKKyAgICAgICAgaWYgKGx1YV9pc25pbChMLCAzKSA9 PSAxKSB7CisgICAgICAgICAgICB2YWx1ZSA9IGFwcl90YWJsZV9nZXQoci0+aGVhZGVyc19vdXQs IGtleSk7CisgICAgICAgICAgICBpZiAodmFsdWUpIHsKKyAgICAgICAgICAgICAgICBhcHJfdGFi bGVfdW5zZXQoci0+aGVhZGVyc19vdXQsIGtleSk7CisgICAgICAgICAgICB9CisgICAgICAgIH0K KyAgICAgICAgZWxzZSB7CisgICAgICAgICAgICB2YWx1ZSA9IGx1YUxfY2hlY2tzdHJpbmcoTCwg Myk7CisgICAgICAgICAgICBhcHJfdGFibGVfc2V0KHItPmhlYWRlcnNfb3V0LCBrZXksIHZhbHVl KTsKKyAgICAgICAgfSAgICAgICAgCisgICAgfQorCisgICAgcmV0dXJuIDE7Cit9CisKIC8qIGhh bmRsZSByLnN0YXR1cyA9IDIwMSAqLwogc3RhdGljIGludCByZXFfbmV3aW5kZXgobHVhX1N0YXRl ICpMKQogewpAQCAtNjA0LDYgKzYzOSw4IEBACiAKICAgICBhcHJfaGFzaF9zZXQoZGlzcGF0Y2gs ICJoZWFkZXJzX2luIiwgQVBSX0hBU0hfS0VZX1NUUklORywKICAgICAgICAgICAgICAgICAgbWFr ZWZ1bigmcmVxX2hlYWRlcnNfaW4sIEFQTF9SRVFfRlVOVFlQRV9MVUFDRlVOLCBwKSk7CisgICAg YXByX2hhc2hfc2V0KGRpc3BhdGNoLCAiaGVhZGVyc19vdXQiLCBBUFJfSEFTSF9LRVlfU1RSSU5H LAorICAgICAgICAgICAgICAgICBtYWtlZnVuKCZyZXFfaGVhZGVyc19vdXQsIEFQTF9SRVFfRlVO VFlQRV9MVUFDRlVOLCBwKSk7CiAKICAgICBsdWFfcHVzaGxpZ2h0dXNlcmRhdGEoTCwgZGlzcGF0 Y2gpOwogICAgIGx1YV9zZXRmaWVsZChMLCBMVUFfUkVHSVNUUllJTkRFWCwgIkFwYWNoZTIuUmVx dWVzdC5kaXNwYXRjaCIpOwpAQCAtNjY4LDQgKzcwNSw0IEBACiAgICAgbHVhX2JveHBvaW50ZXIo TCwgcik7CiAgICAgbHVhTF9nZXRtZXRhdGFibGUoTCwgIkFwYWNoZTIuUmVxdWVzdCIpOwogICAg IGx1YV9zZXRtZXRhdGFibGUoTCwgLTIpOwotfQpcIE5vIG5ld2xpbmUgYXQgZW5kIG9mIGZpbGUK K30K ------=_Part_269170_30733771.1231676510783--