Apache Mod-Python - [PATCH] Expose ap_meets_conditions()

This is Interesting: Free IT Magazines  
Home > Archive > Apache Mod-Python > April 2005 > [PATCH] Expose ap_meets_conditions()





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author [PATCH] Expose ap_meets_conditions()
Sander Striker

2005-04-18, 5:45 pm

Hi,

Small patch to expose ap_meets_conditions(). Documentation could use
some review. Also note that I haven't run the documentation through
a validator/generator...

Sander


Log:
Expose ap_meets_conditions() to allow for easier checking of conditional
headers. Primarily meant to facilitate caching.

* src/requestobject.c

(req_meets_conditions): New function. Simple wrapper around
ap_meets_conditions().


* Doc/modpython4.tex

(meets_conditions): New documentation blurb.

Index: src/requestobject.c
========================================
===========================
--- src/requestobject.c (revision 161666)
+++ src/requestobject.c (working copy)
@@ -419,6 +419,17 @@
}

/**
+ ** request.meets_conditions(req self)
+ **
+ * ap_meets_conditions wrapper
+ */
+
+static PyObject * req_meets_conditions(requestobject *self)
+{
+ return PyInt_FromLong(ap_meets_conditions(self->request_rec));
+}
+
+/**
** request.read(request self, int bytes)
**
* Reads stuff like POST requests from the client
@@ -951,6 +962,7 @@
{"get_options", (PyCFunction) req_get_options, METH_NOARGS},
{"internal_redirect", (PyCFunction) req_internal_redirect, METH_VARARGS},
{"log_error", (PyCFunction) req_log_error, METH_VARARGS},
+ {"meets_conditions", (PyCFunction) req_meets_conditions, METH_NOARGS},
{"read", (PyCFunction) req_read, METH_VARARGS},
{"readline", (PyCFunction) req_readline, METH_VARARGS},
{"readlines", (PyCFunction) req_readlines, METH_VARARGS},
Index: Doc/modpython4.tex
========================================
===========================
--- Doc/modpython4.tex (revision 161666)
+++ Doc/modpython4.tex (working copy)
@@ -656,6 +656,30 @@
use the \function{apache.log_error} function.
\end{methoddesc}

+\begin{methoddesc}[request]{meets_conditions}{}
+ Calls the Apache \cfunction{ap_meets_conditions()} function which
+ returns a status code. If \var{status} is \constant{apache.OK}, generate
+ the content of the response normally. If not, simply return \var{status}.
+ Note that \member{req.headers_out} should be set prior to calling this
+ function. The same goes for \member{req.status} if the status differs
+ from \constant{apache.OK}.
+
+ Example:
+ \begin{verbatim}
+...
+r.headers_out['ETag'] = "1130794f-3774-4584-a4ea-0ab19e684268"
+r.headers_out['Last-Modified'] = 'Wed, 23 Feb 2005 00:00:00 GMT'
+r.headers_out['Expires'] = 'Mon, 18 Apr 2005 17:30:00 GMT'
+
+status = r.meets_conditions()
+if status != apache.OK:
+ return status
+
+... do expensive generation of the response content ...
+ \end{verbatim}
+
+\end{methoddesc}
+
\begin{methoddesc}[request]{requires}{}

Returns a tuple of strings of arguments to \code{require} directive.

Nicolas Lehuen

2005-04-18, 5:45 pm

On 4/18/05, Sander Striker <striker@apache.org> wrote:
> Hi,
>=20
> Small patch to expose ap_meets_conditions(). Documentation could use
> some review. Also note that I haven't run the documentation through
> a validator/generator...
>=20
> Sander
>=20
> Log:
> Expose ap_meets_conditions() to allow for easier checking of conditional
> headers. Primarily meant to facilitate caching.
>=20
> * src/requestobject.c
>=20
> (req_meets_conditions): New function. Simple wrapper around
> ap_meets_conditions().
>=20
> * Doc/modpython4.tex
>=20
> (meets_conditions): New documentation blurb.
>=20


[snipped : patch]

OK, I've checked this in.

I had to make the changes by hand since I could not convince my patch
program that this was a proper patch. I used "patch -u -i
yourfile.patch" and got errors. Am I using patch (v 2.5.8) correctly ?
Or maybe your patch was mangled by my mail client (I use Gmail) ?

Regards,
Nicolas

Sander Striker

2005-04-18, 5:45 pm

Nicolas Lehuen wrote:
> OK, I've checked this in.


Thanks. Reviewed it first I hope? ;)

> I had to make the changes by hand since I could not convince my patch
> program that this was a proper patch. I used "patch -u -i
> yourfile.patch" and got errors. Am I using patch (v 2.5.8) correctly ?


I usually just 'cat <<EOF | patch -p0', which is more or less the same as
you did.

> Or maybe your patch was mangled by my mail client (I use Gmail) ?


Or maybe my patch was mangled by my mailer (Thunderbird). Just proves
to me that even with a different mailer I should attach patches...

Sander

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com