You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by jo...@apache.org on 2003/02/27 21:03:59 UTC
cvs commit: httpd-apreq/t cookie.t request-param.pl request.t
joes 2003/02/27 12:03:59
Modified: . Changes ToDo
Request Request.xs
c apache_request.c apache_request.h
t cookie.t request-param.pl request.t
Log:
Add req->nargs.
Revision Changes Path
1.46 +5 -0 httpd-apreq/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/httpd-apreq/Changes,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- Changes 8 Jan 2003 04:47:34 -0000 1.45
+++ Changes 27 Feb 2003 20:03:58 -0000 1.46
@@ -2,6 +2,11 @@
=over 4
+=item 1.11 - February 27, 2003
+
+Add req->nargs to C API to distinguish between query string and
+request body params.
+
=item 1.05 - January 5, 2003
Include patch and supporting documentation for OS X [David Wheeler].
1.10 +1 -5 httpd-apreq/ToDo
Index: ToDo
===================================================================
RCS file: /home/cvs/httpd-apreq/ToDo,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ToDo 27 Nov 2002 02:06:29 -0000 1.9
+++ ToDo 27 Feb 2003 20:03:58 -0000 1.10
@@ -16,12 +16,8 @@
o Fix our Apache::Test-based test suite
-o Document build/install process for OS X.
-
-o optional build/link of libapreq.a directly into httpd?
-
o solve the memory leak for:
my $r = shift;
$r = Apache::Request->new($r);
as discussed at:
- http://marc.theaimsgroup.com/?t=102615343600005&r=1&w=2
\ No newline at end of file
+ http://marc.theaimsgroup.com/?t=102615343600005&r=1&w=2
1.33 +24 -0 httpd-apreq/Request/Request.xs
Index: Request.xs
===================================================================
RCS file: /home/cvs/httpd-apreq/Request/Request.xs,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- Request.xs 8 Jan 2003 04:47:34 -0000 1.32
+++ Request.xs 27 Feb 2003 20:03:58 -0000 1.33
@@ -342,6 +342,30 @@
ApacheRequest_parse(req)
Apache::Request req
+
+Apache::Table
+ApacheRequest_query_params(req)
+ Apache::Request req
+
+ PREINIT:
+ table *parms;
+
+ CODE:
+ parms = ApacheRequest_query_params(req, req->r->pool);
+ ST(0) = mod_perl_tie_table(parms);
+
+Apache::Table
+ApacheRequest_post_params(req)
+ Apache::Request req
+
+ PREINIT:
+ table *parms;
+
+ CODE:
+ parms = ApacheRequest_post_params(req, req->r->pool);
+ ST(0) = mod_perl_tie_table(parms);
+
+
void
ApacheRequest_parms(req, parms=NULL)
Apache::Request req
1.22 +28 -0 httpd-apreq/c/apache_request.c
Index: apache_request.c
===================================================================
RCS file: /home/cvs/httpd-apreq/c/apache_request.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- apache_request.c 20 Jun 2002 05:10:07 -0000 1.21
+++ apache_request.c 27 Feb 2003 20:03:58 -0000 1.22
@@ -167,6 +167,32 @@
return retval;
}
+table *ApacheRequest_query_params(ApacheRequest *req, ap_pool *p)
+{
+ array_header *a = ap_palloc(p, sizeof *a);
+ array_header *b = (array_header *)req->parms;
+
+ a->elts = b->elts;
+ a->nelts = req->nargs;
+
+ a->nalloc = a->nelts; /* COW hack: array push will induce copying */
+ a->elt_size = sizeof(table_entry);
+ return (table *)a;
+}
+
+table *ApacheRequest_post_params(ApacheRequest *req, ap_pool *p)
+{
+ array_header *a = ap_palloc(p, sizeof *a);
+ array_header *b = (array_header *)req->parms;
+
+ a->elts = (void *)( (table_entry *)b->elts + req->nargs );
+ a->nelts = b->nelts - req->nargs;
+
+ a->nalloc = a->nelts; /* COW hack: array push will induce copying */
+ a->elt_size = sizeof(table_entry);
+ return (table *)a;
+}
+
ApacheUpload *ApacheUpload_new(ApacheRequest *req)
{
ApacheUpload *upload = (ApacheUpload *)
@@ -210,6 +236,7 @@
req->temp_dir = NULL;
req->parsed = 0;
req->r = r;
+ req->nargs = 0;
return req;
}
@@ -264,6 +291,7 @@
if (r->args) {
split_to_parms(req, r->args);
+ req->nargs = ((array_header *)req->parms)->nelts;
}
if (r->method_number == M_POST) {
1.10 +3 -0 httpd-apreq/c/apache_request.h
Index: apache_request.h
===================================================================
RCS file: /home/cvs/httpd-apreq/c/apache_request.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- apache_request.h 5 Nov 2002 00:07:16 -0000 1.9
+++ apache_request.h 27 Feb 2003 20:03:58 -0000 1.10
@@ -45,6 +45,7 @@
void *hook_data;
char* temp_dir;
request_rec *r;
+ int nargs;
} ApacheRequest;
struct ApacheUpload {
@@ -97,6 +98,8 @@
int ApacheRequest___parse(ApacheRequest *req);
#define ApacheRequest_parse(req) \
(req->status = req->parsed ? req->status : ApacheRequest___parse(req))
+table *ApacheRequest_query_params(ApacheRequest *req, ap_pool *p);
+table *ApacheRequest_post_params(ApacheRequest *req, ap_pool *p);
FILE *ApacheRequest_tmpfile(ApacheRequest *req, ApacheUpload *upload);
ApacheUpload *ApacheUpload_new(ApacheRequest *req);
1.2 +1 -1 httpd-apreq/t/cookie.t
Index: cookie.t
===================================================================
RCS file: /home/cvs/httpd-apreq/t/cookie.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cookie.t 17 Nov 2002 23:14:22 -0000 1.1
+++ cookie.t 27 Feb 2003 20:03:58 -0000 1.2
@@ -1,5 +1,5 @@
+#!perl
use strict;
-use Apache::test qw(skip_test have_httpd test have_module);
use Apache::src ();
#use lib qw(lib blib/lib blib/arch);
eval 'require Apache::Cookie' or die $@;
1.2 +5 -0 httpd-apreq/t/request-param.pl
Index: request-param.pl
===================================================================
RCS file: /home/cvs/httpd-apreq/t/request-param.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- request-param.pl 17 Nov 2002 23:14:22 -0000 1.1
+++ request-param.pl 27 Feb 2003 20:03:58 -0000 1.2
@@ -24,3 +24,8 @@
print $/;
}
+for my $table ($apr->query_params, $apr->post_params) {
+ my ($k,$v) = each %$table;
+ print "param $k => $v$/";
+}
+
1.2 +4 -2 httpd-apreq/t/request.t
Index: request.t
===================================================================
RCS file: /home/cvs/httpd-apreq/t/request.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- request.t 17 Nov 2002 23:14:22 -0000 1.1
+++ request.t 27 Feb 2003 20:03:58 -0000 1.2
@@ -54,13 +54,13 @@
param_test(sub {
my($url, $data) = @_;
- HTTP::Request::Common::GET("$url?$data");
+ HTTP::Request::Common::GET("$url;$data");
});
}
sub param_test {
my $cv = shift;
- my $url = "http://localhost:$ENV{PORT}/request-param.pl";
+ my $url = "http://localhost:$ENV{PORT}/request-param.pl?key=val";
my $data =
"ONE=ONE_value&TWO=TWO_value&" .
"THREE=M1&THREE=M2&THREE=M3";
@@ -70,9 +70,11 @@
my $page = $response->content;
print $response->as_string unless $response->is_success;
my $expect = <<EOF;
+param key => val
param ONE => ONE_value
param TWO => TWO_value
param THREE => M1,M2,M3
+param key => val
EOF
my $ok = $page eq $expect;
test ++$i, $ok;