Re: understanding apr_strtok()

2008-12-13 Thread Sam Carleton
On Sat, Dec 13, 2008 at 2:35 AM, Saju Pillai saju.pil...@gmail.com wrote:

 On 13-Dec-08, at 1:02 PM, Mark Harrison wrote:

 One thing you can check:
 Make sure that s points to writable memory.


 Check that s is on the heap not on a function stack. Try apr_pstrdup(p, s)
 or memcpy(s) into malloc'd memory.

Thank you, that was the issue!

Sam


Re: internal redirect

2008-12-13 Thread Sorin Manolache
On Sat, Dec 13, 2008 at 18:52, Sam Carleton scarle...@miltonstreet.com wrote:
 I thought I had seen a way to do an internal redirect in a module such
 that the browser would never be the wiser.  Is there?  If so, how do I
 do it?

 The reason is that I have coded myself into a hole.  I have a kiosk
 based system using Apache as the server and a custom application that
 wraps the IE7 WebControl as the client.  I have made changes to both
 client and server that checks the versions of both and makes sure they
 are in sync.  The in the module is done in the access checker hook.
 Right now I am using the standard HTML Location header to redirect to
 the error page.  The problem I have is that the client that is in the
 field sees that as an error and displays my almost useless error box
 to my customer, not a nice web page to inform them to upgrade the
 client.

 So the question is:  Within the access checker hook, how can I change
 the URL for this request so the browser sees a successful request but
 gets a different page?

I don't know which of them applies to your application, but here are a
couple of possible solutions:

1. Set the Location response header to your URL
(apr_table_set(r-headers_out, Location, url)) and return
HTTP_MOVED_TEMPORARILY (i.e. 302) from access_checker. Or:
2. Return a non-OK and non-DECLINED value from access_checker and put
an ErrorDocument returned_code /url in your Location. Or:
3. Set a request note (apr_table_set(r-notes, my_note,
should_redirect)) and then in the handler hook you check the request
note. If it is set, ap_internal_redirect(your_url).

Hope this helps,
S

-- 
A: Because it reverses the logical flow of conversation.
Q: Why is top-posting frowned upon?
A: Top-posting.
Q: What is the most annoying thing in e-mail?


Re: internal redirect

2008-12-13 Thread Sam Carleton
On Sat, Dec 13, 2008 at 1:04 PM, Sorin Manolache sor...@gmail.com wrote:

 3. Set a request note (apr_table_set(r-notes, my_note,
 should_redirect)) and then in the handler hook you check the request
 note. If it is set, ap_internal_redirect(your_url).

This is what I want to do, make it 100% transparent to the client.  I
put my hook handler at the first one and look for the note, if there I
call ap_internal_redirect(), but my client is still getting a status
code of 500.  The page I am trying to redirect to *IS* a PHP page,
does that matter?  What format should the string in
ap_internal_redirect() take, relative to the server or should the http
and the server name be part of the string?  I want to redirect to:

/invalidClient.html

Sam