Author: joes
Date: Sat Apr 23 11:34:45 2005
New Revision: 164406
URL: http://svn.apache.org/viewcvs?rev=164406&view=rev
Log:
- Perl API [joes]
Move bake, bake2 to Apache2::Cookie, now requiring
an extra $r argument. Also ""-operator is mapped
to as_string() for Apache2::Cookie; but APR::Request::Cookie
maps it to value().
- C API [joes]
Remove header_in & header_out from apreq_module_t.
Remove apreq_ua_cookie_version() and apreq_cookie_bake*().
Remove cookie2 argument to apreq_handle_custom().
Modified:
httpd/apreq/trunk/CHANGES
httpd/apreq/trunk/STATUS
httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm
httpd/apreq/trunk/glue/perl/t/apreq/cgi.t
httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm
httpd/apreq/trunk/glue/perl/xsbuilder/maps/apreq_functions.map
httpd/apreq/trunk/include/apreq_module.h
httpd/apreq/trunk/library/module.c
httpd/apreq/trunk/library/module_cgi.c
httpd/apreq/trunk/library/module_custom.c
httpd/apreq/trunk/library/t/cookie.c
httpd/apreq/trunk/module/apache2/handle.c
httpd/apreq/trunk/module/t/c-modules/apreq_cookie_test/mod_apreq_cookie_test.c
httpd/apreq/trunk/module/test_cgi.c
Modified: httpd/apreq/trunk/CHANGES
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/CHANGES?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/CHANGES (original)
+++ httpd/apreq/trunk/CHANGES Sat Apr 23 11:34:45 2005
@@ -5,6 +5,17 @@
@section v2_05_dev Changes with libapreq2-2.05-dev
+- Perl API [joes]
+ Move bake, bake2 to Apache2::Cookie, now requiring
+ an extra $r argument. Also ""-operator is mapped
+ to as_string() for Apache2::Cookie; but APR::Request::Cookie
+ maps it to value().
+
+- C API [joes]
+ Remove header_in & header_out from apreq_module_t.
+ Remove apreq_ua_cookie_version() and apreq_cookie_bake*().
+ Remove cookie2 argument to apreq_handle_custom().
+
- C API [joes]
s/APREQ/APREQ2/g in webserver configuration directives.
Modified: httpd/apreq/trunk/STATUS
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/STATUS?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/STATUS (original)
+++ httpd/apreq/trunk/STATUS Sat Apr 23 11:34:45 2005
@@ -77,8 +77,6 @@
error status should be both tested & documented. Also
upgrade these tests to use the Apache::Test framework.
- - Fix all the "//apreq_log" comments in the cgi tests.
-
- Add a "memory_limit" setting to apreq_parser_t and apreq_module_t,
which will control how much pool allocation the parser may use.
Modified: httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm (original)
+++ httpd/apreq/trunk/glue/perl/lib/Apache2/Cookie.pm Sat Apr 23 11:34:45 2005
@@ -1,7 +1,11 @@
package Apache2::Cookie;
+use APR::Table;
+use APR::Pool;
use APR::Request::Cookie;
use APR::Request::Apache2;
use APR::Request qw/encode decode/;
+use Apache2::RequestRec;
+use overload '""' => sub { shift->as_string() }, fallback => 1;
push our @ISA, "APR::Request::Cookie";
@@ -20,9 +24,7 @@
$k =~ s/^-//;
$cookie->$k($v);
}
- $r = APR::Request::Apache2->new($r) unless $r->isa("APR::Request");
- $cookie->bind_handle($r);
- $cookie;
+ return $cookie;
}
@@ -68,14 +70,26 @@
}
sub thaw {
- my $self = shift;
- my @rv = split /&/, @_ ? shift : "$self";
+ my $c = shift;
+ my @rv = split /&/, @_ ? shift : $c->SUPER::value;
return wantarray ? map decode($_), @rv : decode($rv[0]);
}
sub value {
return shift->thaw;
}
+
+sub bake {
+ my ($c, $r) = @_;
+ $r->err_headers_out->add("Set-Cookie", $c->as_string);
+}
+
+sub bake2 {
+ my ($c, $r) = @_;
+ die "Can't bake2 a Netscape cookie: $c" unless $c->version > 0;
+ $r->err_headers_out->add("Set-Cookie2", $c->as_string);
+}
+
package Apache2::Cookie::Jar;
use APR::Request::Apache2;
Modified: httpd/apreq/trunk/glue/perl/t/apreq/cgi.t
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/t/apreq/cgi.t?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/t/apreq/cgi.t (original)
+++ httpd/apreq/trunk/glue/perl/t/apreq/cgi.t Sat Apr 23 11:34:45 2005
@@ -246,12 +246,10 @@
apreq_log("Fetching cookie $key");
if ($cookies{$key}) {
if ($test eq "bake") {
- $cookies{$key}->is_tainted(0);
- $cookies{$key}->bake;
+ printf "Set-Cookie: %s\n", $cookies{$key}->as_string;
}
elsif ($test eq "bake2") {
- $cookies{$key}->is_tainted(0);
- $cookies{$key}->bake2;
+ printf "Set-Cookie2: %s\n", $cookies{$key}->as_string;
}
print "Content-Type: text/plain\n\n";
print APR::Request::decode($cookies{$key}->value);
Modified: httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm (original)
+++ httpd/apreq/trunk/glue/perl/t/response/TestApReq/cookie.pm Sat Apr 23
11:34:45 2005
@@ -21,12 +21,10 @@
if ($key and $cookies{$key}) {
if ($test eq "bake") {
- $cookies{$key}->is_tainted(0);
- $cookies{$key}->bake;
+ $cookies{$key}->bake($r);
}
elsif ($test eq "bake2") {
- $cookies{$key}->is_tainted(0);
- $cookies{$key}->bake2;
+ $cookies{$key}->bake2($r);
}
$r->print($cookies{$key}->value);
}
@@ -35,7 +33,7 @@
@expires = ("expires", $req->APR::Request::args('expires'))
if $req->APR::Request::args('expires');
my $cookie = Apache2::Cookie->new($r, name => "foo",
- value => "bar", @expires);
+ value => "bar", @expires);
if ($test eq "bake") {
$cookie->bake($req);
}
Modified: httpd/apreq/trunk/glue/perl/xsbuilder/maps/apreq_functions.map
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/glue/perl/xsbuilder/maps/apreq_functions.map?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/xsbuilder/maps/apreq_functions.map (original)
+++ httpd/apreq/trunk/glue/perl/xsbuilder/maps/apreq_functions.map Sat Apr 23
11:34:45 2005
@@ -107,8 +107,6 @@
MODULE=APR::Request PACKAGE=APR::Request PREFIX=apreq_
apreq_hook_add
-apreq_header_in
-apreq_header_out
MODULE=APR::Request PACKAGE=APR::Request PREFIX=APR__Request_
DEFINE_parse | apreq_xs_parse |
@@ -124,8 +122,6 @@
#################### APR::Request::Cookie stuff ####################
MODULE=APR::Request::Cookie PACKAGE=APR::Request::Cookie PREFIX=apreq_cookie_
-apreq_cookie_bake | (c, req) | apreq_cookie_t *:c,
req=apreq_xs_sv2handle(aTHX_ ST(0))
-apreq_cookie_bake2| (c, req) | apreq_cookie_t *:c,
req=apreq_xs_sv2handle(aTHX_ ST(0))
apreq_cookie_expires
MODULE=APR::Request::Cookie PACKAGE=APR::Request PREFIX=APR__Request_
Modified: httpd/apreq/trunk/include/apreq_module.h
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/include/apreq_module.h?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/include/apreq_module.h (original)
+++ httpd/apreq/trunk/include/apreq_module.h Sat Apr 23 11:34:45 2005
@@ -89,11 +89,6 @@
/** set the directory used by the parser for temporary files */
apr_status_t (*temp_dir_set)(apreq_handle_t *, const char *);
- /** get the value of a request header */
- const char *(*header_in)(apreq_handle_t *,const char *);
- /** send a response header */
- apr_status_t (*header_out)(apreq_handle_t *, const char *,char *);
-
} apreq_module_t;
@@ -257,38 +252,6 @@
/**
- * Fetch the header value (joined by ", " if there are multiple headers)
- * for a given header name.
- *
- * @param req The request handle.
- * @param name The header name.
- *
- * @return The value of the header, or NULL if not found.
- */
-static APR_INLINE
-const char *apreq_header_in(apreq_handle_t *req, const char *name)
-{
- return req->module->header_in(req, name);
-}
-
-
-/**
- * Add a header field to the environment's outgoing response headers
- *
- * @param req The request handle
- * @param name The name of the outgoing header.
- * @param val Value of the outgoing header.
- *
- * @return APR_SUCCESS or module-specific error code.
- */
-static APR_INLINE
-apr_status_t apreq_header_out(apreq_handle_t *req,
- const char *name, char *val)
-{
- return req->module->header_out(req, name, val);
-}
-
-/**
* Set the active brigade limit.
*
* @param req The handle.
@@ -402,7 +365,7 @@
pre##_brigade_limit_get, pre##_brigade_limit_set, \
pre##_read_limit_get, pre##_read_limit_set, \
pre##_temp_dir_get, pre##_temp_dir_set, \
- pre##_header_in, pre##_header_out }
+ }
/**
@@ -426,7 +389,6 @@
* @param pool allocates the parse data,
* @param query_string parsed into args table
* @param cookie value of the request "Cookie" header
- * @param cookie2 value of the request "Cookie2" header
* @param parser parses the request body
* @param read_limit maximum bytes to read from the body
* @param in brigade containing the request body
@@ -436,7 +398,6 @@
APREQ_DECLARE(apreq_handle_t*) apreq_handle_custom(apr_pool_t *pool,
const char *query_string,
const char *cookie,
- const char *cookie2,
apreq_parser_t *parser,
apr_uint64_t read_limit,
apr_bucket_brigade *in);
Modified: httpd/apreq/trunk/library/module.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/library/module.c?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/library/module.c (original)
+++ httpd/apreq/trunk/library/module.c Sat Apr 23 11:34:45 2005
@@ -20,74 +20,6 @@
#include "apr_lib.h"
#include "apr_file_io.h"
-
-
-static int has_rfc_cookie(void *ctx, const char *key, const char *val)
-{
- const apreq_cookie_t *c = apreq_value_to_cookie(val);
-
- /* 0 -> non-netscape cookie found, stop.
- 1 -> not found, keep going. */
-
- return apreq_cookie_version(c);
-}
-
-APREQ_DECLARE(unsigned)
- apreq_ua_cookie_version(apreq_handle_t *env)
-{
-
- if (apreq_header_in(env, "Cookie2") == NULL) {
- const apr_table_t *j;
-
- if (apreq_jar(env, &j) != APR_SUCCESS
- || apr_table_do(has_rfc_cookie, NULL, j, NULL) == 1)
- return 0;
-
- else
- return 1;
- }
- else
- return 1;
-}
-
-
-APREQ_DECLARE(apr_status_t) apreq_cookie_bake(const apreq_cookie_t *c,
- apreq_handle_t *req)
-{
- char s[APREQ_COOKIE_MAX_LENGTH];
- int len;
- if (apreq_cookie_is_tainted(c))
- return APREQ_ERROR_TAINTED;
-
- len = apreq_cookie_serialize(c, s, APREQ_COOKIE_MAX_LENGTH);
-
- if (len >= APREQ_COOKIE_MAX_LENGTH)
- return APREQ_ERROR_OVERLIMIT;
-
- return apreq_header_out(req, "Set-Cookie", s);
-}
-
-APREQ_DECLARE(apr_status_t) apreq_cookie_bake2(const apreq_cookie_t *c,
- apreq_handle_t *req)
-{
- char s[APREQ_COOKIE_MAX_LENGTH];
- int len;
-
- if (apreq_cookie_is_tainted(c))
- return APREQ_ERROR_TAINTED;
-
- len = apreq_cookie_serialize(c, s, APREQ_COOKIE_MAX_LENGTH);
-
- if (apreq_cookie_version(c) == 0)
- return APREQ_ERROR_MISMATCH;
-
- if (len >= APREQ_COOKIE_MAX_LENGTH)
- return APREQ_ERROR_OVERLIMIT;
-
- return apreq_header_out(req, "Set-Cookie2", s);
-}
-
-
APREQ_DECLARE(apreq_param_t *)apreq_param(apreq_handle_t *req, const char *key)
{
apreq_param_t *param = apreq_args_get(req, key);
@@ -96,7 +28,6 @@
else
return param;
}
-
APREQ_DECLARE(apr_table_t *)apreq_params(apreq_handle_t *req, apr_pool_t *p)
{
Modified: httpd/apreq/trunk/library/module_cgi.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/library/module_cgi.c?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/library/module_cgi.c (original)
+++ httpd/apreq/trunk/library/module_cgi.c Sat Apr 23 11:34:45 2005
@@ -164,21 +164,6 @@
}
-static apr_status_t cgi_header_out(apreq_handle_t *env, const char *name,
- char *value)
-{
- struct cgi_handle *handle = (struct cgi_handle *)env;
- apr_pool_t *p = handle->pool;
- apr_file_t *out;
- int bytes;
- apr_status_t s = apr_file_open_stdout(&out, p);
- cgi_log_error(CGILOG_MARK, CGILOG_DEBUG, s, env,
- "Setting header: %s => %s", name, value);
- bytes = apr_file_printf(out, "%s: %s" CRLF, name, value);
- apr_file_flush(out);
- return bytes > 0 ? APR_SUCCESS : APREQ_ERROR_GENERAL;
-}
-
APR_INLINE
static const char *cgi_query_string(apreq_handle_t *env)
Modified: httpd/apreq/trunk/library/module_custom.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/library/module_custom.c?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/library/module_custom.c (original)
+++ httpd/apreq/trunk/library/module_custom.c Sat Apr 23 11:34:45 2005
@@ -250,40 +250,11 @@
}
-
-
-static const char *custom_header_in(apreq_handle_t *env,
- const char *name)
-{
- struct custom_handle *handle = (struct custom_handle*)env;
-
- if (strcasecmp(name, "Content-Type") == 0)
- return handle->parser->content_type;
- else if (strcasecmp(name, "Cookie") == 0)
- return handle->cookie_header;
- else if (strcasecmp(name, "Cookie2") == 0)
- return handle->cookie2_header;
- else
- return NULL;
-}
-
-static apr_status_t custom_header_out(apreq_handle_t *env, const char *name,
- char *value)
-{
- (void)env;
- (void)name;
- (void)value;
-
- return APR_ENOTIMPL;
-}
-
-
static APREQ_MODULE(custom, 20050130);
APREQ_DECLARE(apreq_handle_t*) apreq_handle_custom(apr_pool_t *pool,
const char
*query_string,
const char *cookie,
- const char *cookie2,
apreq_parser_t *parser,
apr_uint64_t read_limit,
apr_bucket_brigade *in)
@@ -292,7 +263,6 @@
handle = apr_palloc(pool, sizeof(*handle));
handle->env.module = &custom_module;
handle->cookie_header = cookie;
- handle->cookie2_header = cookie2;
handle->read_limit = read_limit;
handle->parser = parser;
handle->in = in;
Modified: httpd/apreq/trunk/library/t/cookie.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/library/t/cookie.c?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/library/t/cookie.c (original)
+++ httpd/apreq/trunk/library/t/cookie.c Sat Apr 23 11:34:45 2005
@@ -157,16 +157,6 @@
}
-static void ua_version(dAT)
-{
- apreq_handle_t *ns, *rfc;
-
- ns = apreq_handle_custom(p, NULL, NULL, NULL, NULL, 0, NULL);
- AT_int_eq(apreq_ua_cookie_version(ns), 0);
-
- rfc = apreq_handle_custom(p, NULL, NULL, "$Version=\"1\"", NULL, 0, NULL);
- AT_int_eq(apreq_ua_cookie_version(rfc), 1);
-}
#define dT(func, plan) #func, func, plan
@@ -181,7 +171,6 @@
{ dT(jar_get_ns, 10) },
{ dT(netscape_cookie, 7) },
{ dT(rfc_cookie, 6) },
- { dT(ua_version, 2) }
};
apr_initialize();
Modified: httpd/apreq/trunk/module/apache2/handle.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/module/apache2/handle.c?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/module/apache2/handle.c (original)
+++ httpd/apreq/trunk/module/apache2/handle.c Sat Apr 23 11:34:45 2005
@@ -134,20 +134,6 @@
}
-static const char *apache2_header_in(apreq_handle_t *env, const char *name)
-{
- struct apache2_handle *handle = (struct apache2_handle *)env;
- return apr_table_get(handle->r->headers_in, name);
-}
-
-static apr_status_t apache2_header_out(apreq_handle_t *env,
- const char *name, char *value)
-{
- struct apache2_handle *handle = (struct apache2_handle *)env;
- apr_table_add(handle->r->err_headers_out, name, value);
- return APR_SUCCESS;
-}
-
static apr_status_t apache2_body(apreq_handle_t *req, const apr_table_t **t)
{
ap_filter_t *f = get_apreq_filter(req);
Modified:
httpd/apreq/trunk/module/t/c-modules/apreq_cookie_test/mod_apreq_cookie_test.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/module/t/c-modules/apreq_cookie_test/mod_apreq_cookie_test.c?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
---
httpd/apreq/trunk/module/t/c-modules/apreq_cookie_test/mod_apreq_cookie_test.c
(original)
+++
httpd/apreq/trunk/module/t/c-modules/apreq_cookie_test/mod_apreq_cookie_test.c
Sat Apr 23 11:34:45 2005
@@ -72,12 +72,12 @@
ap_set_content_type(r, "text/plain");
if (strcmp(test, "bake") == 0) {
- apreq_cookie_tainted_off(cookie);
- s = apreq_cookie_bake(cookie, req);
+ apr_table_add(r->headers_out, "Set-Cookie",
+ apreq_cookie_as_string(cookie, r->pool));
}
else if (strcmp(test, "bake2") == 0) {
- apreq_cookie_tainted_off(cookie);
- s = apreq_cookie_bake2(cookie, req);
+ apr_table_add(r->headers_out, "Set-Cookie2",
+ apreq_cookie_as_string(cookie, r->pool));
}
else {
size = strlen(cookie->v.data);
@@ -86,9 +86,6 @@
if (s == APR_SUCCESS)
ap_rprintf(r, "%s", dest);
}
-
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, s, r,
- "finished cookie tests");
return OK;
}
Modified: httpd/apreq/trunk/module/test_cgi.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/trunk/module/test_cgi.c?rev=164406&r1=164405&r2=164406&view=diff
==============================================================================
--- httpd/apreq/trunk/module/test_cgi.c (original)
+++ httpd/apreq/trunk/module/test_cgi.c Sat Apr 23 11:34:45 2005
@@ -30,6 +30,13 @@
return 1;
}
+#define cookie_bake(c) apr_file_printf(out, "Set-Cookie: %s\n", \
+ apreq_cookie_as_string(c, pool))
+
+#define cookie_bake2(c) apr_file_printf(out, "Set-Cookie2: %s\n", \
+ apreq_cookie_as_string(c, pool))
+
+
int main(int argc, char const * const * argv)
{
apr_pool_t *pool;
@@ -57,10 +64,6 @@
apr_file_open_stdout(&out, pool);
-// apreq_log(APREQ_DEBUG 0, env, "%s", "Creating apreq_request");
-
-// apreq_log(APREQ_DEBUG 0, env, "%s", "Fetching the parameters");
-
foo = apreq_param(req, "foo");
bar = apreq_param(req, "bar");
@@ -72,11 +75,9 @@
if (foo) {
apr_file_printf(out, "\t%s => %s\n", "foo", foo->v.data);
-// apreq_log(APREQ_DEBUG 0, env, "%s => %s", "foo", foo->v.data);
}
if (bar) {
apr_file_printf(out, "\t%s => %s\n", "bar", bar->v.data);
-// apreq_log(APREQ_DEBUG 0, env, "%s => %s", "bar", bar->v.data);
}
}
@@ -85,22 +86,17 @@
char *dest;
apr_size_t dlen;
-// apreq_log(APREQ_DEBUG 0, env, "Fetching Cookie %s", key->v.data);
cookie = apreq_cookie(req, key->v.data);
if (cookie == NULL) {
-// apreq_log(APREQ_DEBUG APR_EGENERAL, env,
-// "No cookie for %s found!", key->v.data);
exit(-1);
}
if (strcmp(test->v.data, "bake") == 0) {
- apreq_cookie_tainted_off(cookie);
- apreq_cookie_bake(cookie, req);
+ cookie_bake(cookie);
}
else if (strcmp(test->v.data, "bake2") == 0) {
- apreq_cookie_tainted_off(cookie);
- apreq_cookie_bake2(cookie, req);
+ cookie_bake2(cookie);
}
apr_file_printf(out, "%s", "Content-Type: text/plain\n\n");
@@ -109,9 +105,6 @@
cookie->v.dlen) == APR_SUCCESS)
apr_file_printf(out, "%s", dest);
else {
-// apreq_log(APREQ_ERROR APR_EGENERAL, env,
-// "Bad cookie encoding: %s",
-// cookie->v.data);
exit(-1);
}
}
@@ -121,10 +114,7 @@
int count = 0;
apr_file_printf(out, "%s", "Content-Type: text/plain\n\n");
-// apreq_log(APREQ_DEBUG 0, env, "Fetching all parameters");
-
if (params == NULL) {
-// apreq_log(APREQ_ERROR APR_EGENERAL, env, "No parameters found!");
exit(-1);
}
apr_table_do(dump_table, &count, params, NULL);