Re: cookie handling functions

2010-09-15 Thread Neil Erdwien
Excellent -- this is exactly what I was looking for.  I've set it up and 
it works great.


BTW, pay attention when it says to use gmake on Solaris.  :-)

Thanks.


On 9/15/2010 11:46 AM, Brian McQueen wrote:

I think apreq has that.  If you don't have it already, get it and
you'll be glad you did.  Look at its header files.  Lots of good stuff
in them.

On Wed, Sep 15, 2010 at 9:34 AM, Neil Erdwien  wrote:

I'm writing a filter module that needs to inspect cookie values sent with
the request.

Getting the cookie string is easy via:

   char *s = apr_table_get(r->headers_in, "cookie");

However, this returns the whole cookie string, i.e., something like:

   name=value; name="value"; name="quoted \"value\""

Possibly with $Version, $Path, etc.  RFC 2965 is the spec.

I can write code to parse that out, but...

1.  It is tedious.

2.  Surely this has been done.  Are there functions somewhere inside Apache
HTTPD, and accessible from a filter, that will do something like:

   char *value = get_cookie(r, "cookiename");

3.  Whatever is already coded will probably more faithfully implement the
RFC than what I cook up.

--
Neil Erdwien, n...@k-state.edu, 785-532-4905
Web Technologies Manager
Office of Mediated Education, Kansas State University



--
Neil Erdwien, n...@k-state.edu, 785-532-4905
Web Technologies Manager
Office of Mediated Education, Kansas State University


Re: ap_sub_req_lookup_file vs ap_sub_req_lookup_uri

2010-09-15 Thread Peter Janovsky
apache 2.2.16





From: Ben Noordhuis 
To: modules-dev@httpd.apache.org
Sent: Wed, September 15, 2010 4:03:40 PM
Subject: Re: ap_sub_req_lookup_file vs ap_sub_req_lookup_uri

Peter, what version of Apache are you testing this with?



  

Re: modules architecture issue

2010-09-15 Thread Fabio Kaminski
Hi Nick, thanks for answering..  im reading your book and surfing some
apache code for hacking.. it has been a nice trip
.. and your book is very rich of knowledge! (without it.. only hacking the
code :s) so thanks for that :)

i've done some nginx modules coding too, and apache it's way more productive
and more tuned for app development, the the apr lib it's a great achievement
also..

so, i saw that filters has a good flow mechanism, and since the bytes can be
handled like a stream, i think it would be better to handle and parse that
as they are coming into the channel..

but since i started this 3 days ago.. and i will not pass a huge amount of
data.. i think parsing in the handler with the data ready will be fine.. not
too much to loose there.. (but i like the modular way apache is.. and will
do that in filter when i mastered apache a little more)

i think now my worries will be focusing the db pooling of connections.. and
i will study the db modules a little bit more to understand how it its
done.. (its not a sql db)

thanks for the anwers again..

Fabio

On Wed, Sep 15, 2010 at 5:52 PM, Nick Kew  wrote:

> On Wed, 15 Sep 2010 14:57:25 -0300
> Fabio Kaminski  wrote:
>
> I'm not certain I understand the question, but here goes ...
>
> > and at least for data, i thought use something like  [input filter ->
> > handler -> output filter]
> >
> > where the input filter receives a formated string and parse into a
> internal
> > object struct.. the handler get it
> > and using a rest mechanism (put,delete,get,post) in the handler..
>
> An input filter doesn't strictly speaking asynchronously with your handler,
> but conceptually you should think of it as asynchronous.  If that fits
> your application well, go right ahead.  Otherwise it's probably going to
> be easier to do all that within your handler.  The exception to that is
> if you have functionality that becomes re-usable across multiple
> applications if you put it in a filter.
>
> > the handler then call a db api, for the data operation.. and if is
> something
> > like get.. the output filter decode our internal object struct into
> > the formated string..
>
> That sounds like it should be just fine running asynchronously.  But using
> a filter may still call for more groundwork.  Ideally you should create a
> new bucket type for your internal objects to pass them down the chain.
>
> > i saw the smart filter, but couldnt fire it.. since i didnt see a example
> > module using it..
>
> Smart filtering is a matter for configuration.  If your application
> requires the filters, it should probably manage its own configuration.
> If the filters are optional then by all means leave it to the sysop
> and recommend using mod_filter in your documentation.
>
> --
> Nick Kew
>


Re: modules architecture issue

2010-09-15 Thread Nick Kew
On Wed, 15 Sep 2010 14:57:25 -0300
Fabio Kaminski  wrote:

I'm not certain I understand the question, but here goes ...

> and at least for data, i thought use something like  [input filter ->
> handler -> output filter]
> 
> where the input filter receives a formated string and parse into a internal
> object struct.. the handler get it
> and using a rest mechanism (put,delete,get,post) in the handler..

An input filter doesn't strictly speaking asynchronously with your handler,
but conceptually you should think of it as asynchronous.  If that fits
your application well, go right ahead.  Otherwise it's probably going to
be easier to do all that within your handler.  The exception to that is
if you have functionality that becomes re-usable across multiple
applications if you put it in a filter.

> the handler then call a db api, for the data operation.. and if is something
> like get.. the output filter decode our internal object struct into
> the formated string..

That sounds like it should be just fine running asynchronously.  But using
a filter may still call for more groundwork.  Ideally you should create a
new bucket type for your internal objects to pass them down the chain.

> i saw the smart filter, but couldnt fire it.. since i didnt see a example
> module using it..

Smart filtering is a matter for configuration.  If your application
requires the filters, it should probably manage its own configuration.
If the filters are optional then by all means leave it to the sysop
and recommend using mod_filter in your documentation.

-- 
Nick Kew


Re: modules architecture issue

2010-09-15 Thread Fabio Kaminski
Ben,

I know thats not the traditional way to do it.. and the way i used to do it
too.. but i wanna to scale and use only the resources i really need, been
fast as possible.. so i think nothing better than be apache itself..

besides i see a lot of optimizations and freedom (like caching, or routing,
filters.. etc) geting things from filters or rolling some of my own..

i dont think i could be any better inside some sandbox..

its more a custom thing, trying to achieve good latency-throughput and
resource-aware.. so unless i wanna the easy way.. (wich is not the case)..
why not? :)

On Wed, Sep 15, 2010 at 5:00 PM, Ben Noordhuis  wrote:

> Fabio, do you need a module for this? It sounds like it better belongs
> in an application server like Tomcat.
>


Re: ap_sub_req_lookup_file vs ap_sub_req_lookup_uri

2010-09-15 Thread Ben Noordhuis
Peter, what version of Apache are you testing this with?


Re: modules architecture issue

2010-09-15 Thread Ben Noordhuis
Fabio, do you need a module for this? It sounds like it better belongs
in an application server like Tomcat.


Re: modules architecture issue

2010-09-15 Thread Fabio Kaminski
since SetHandler directive "disable" my filter when fired.. does it disable
all others filters, like cache and session?

On Wed, Sep 15, 2010 at 2:57 PM, Fabio Kaminski wrote:

> Hi all,
>
> im working with apache modules on apache 2.3 for direct application
> development..
>
> and at least for data, i thought use something like  [input filter ->
> handler -> output filter]
>
> where the input filter receives a formated string and parse into a internal
> object struct.. the handler get it
> and using a rest mechanism (put,delete,get,post) in the handler..
>
> the handler then call a db api, for the data operation.. and if is
> something like get.. the output filter decode our internal object struct
> into
> the formated string..
>
> first thing to ask.. its that arquitecture right, since i can do this only
> with a handler.. without the filters.. but what i saw is that there
> classical modules, with practices from apache 1..
> and modules designed with 2.0 and 2.2 in mind..
>
> so, what would be the best practice for this scenario, if you can design
> something targeting 2.4?!
>
> i saw the smart filter, but couldnt fire it.. since i didnt see a example
> module using it..
>
> and with [in filter -> handler -> out filter] scenario, right now if i hook
> a handler.. the filter doesnt fire.. wich make me think in forget about
> filter
> and do it all in the handler.. thatś whats about my question here.. why
> not?
>
> thanks!
>
> Fabio Kaminski
>


modules architecture issue

2010-09-15 Thread Fabio Kaminski
Hi all,

im working with apache modules on apache 2.3 for direct application
development..

and at least for data, i thought use something like  [input filter ->
handler -> output filter]

where the input filter receives a formated string and parse into a internal
object struct.. the handler get it
and using a rest mechanism (put,delete,get,post) in the handler..

the handler then call a db api, for the data operation.. and if is something
like get.. the output filter decode our internal object struct into
the formated string..

first thing to ask.. its that arquitecture right, since i can do this only
with a handler.. without the filters.. but what i saw is that there
classical modules, with practices from apache 1..
and modules designed with 2.0 and 2.2 in mind..

so, what would be the best practice for this scenario, if you can design
something targeting 2.4?!

i saw the smart filter, but couldnt fire it.. since i didnt see a example
module using it..

and with [in filter -> handler -> out filter] scenario, right now if i hook
a handler.. the filter doesnt fire.. wich make me think in forget about
filter
and do it all in the handler.. thatś whats about my question here.. why not?

thanks!

Fabio Kaminski


Re: cookie handling functions

2010-09-15 Thread Brian McQueen
I think apreq has that.  If you don't have it already, get it and
you'll be glad you did.  Look at its header files.  Lots of good stuff
in them.

On Wed, Sep 15, 2010 at 9:34 AM, Neil Erdwien  wrote:
> I'm writing a filter module that needs to inspect cookie values sent with
> the request.
>
> Getting the cookie string is easy via:
>
>   char *s = apr_table_get(r->headers_in, "cookie");
>
> However, this returns the whole cookie string, i.e., something like:
>
>   name=value; name="value"; name="quoted \"value\""
>
> Possibly with $Version, $Path, etc.  RFC 2965 is the spec.
>
> I can write code to parse that out, but...
>
> 1.  It is tedious.
>
> 2.  Surely this has been done.  Are there functions somewhere inside Apache
> HTTPD, and accessible from a filter, that will do something like:
>
>   char *value = get_cookie(r, "cookiename");
>
> 3.  Whatever is already coded will probably more faithfully implement the
> RFC than what I cook up.
>
> --
> Neil Erdwien, n...@k-state.edu, 785-532-4905
> Web Technologies Manager
> Office of Mediated Education, Kansas State University
>


cookie handling functions

2010-09-15 Thread Neil Erdwien
I'm writing a filter module that needs to inspect cookie values sent 
with the request.


Getting the cookie string is easy via:

   char *s = apr_table_get(r->headers_in, "cookie");

However, this returns the whole cookie string, i.e., something like:

   name=value; name="value"; name="quoted \"value\""

Possibly with $Version, $Path, etc.  RFC 2965 is the spec.

I can write code to parse that out, but...

1.  It is tedious.

2.  Surely this has been done.  Are there functions somewhere inside 
Apache HTTPD, and accessible from a filter, that will do something like:


   char *value = get_cookie(r, "cookiename");

3.  Whatever is already coded will probably more faithfully implement 
the RFC than what I cook up.


--
Neil Erdwien, n...@k-state.edu, 785-532-4905
Web Technologies Manager
Office of Mediated Education, Kansas State University