You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Victor Ronin <vi...@gmail.com> on 2011/01/12 20:49:53 UTC
Hook end of connection
Hi,
I need to write a module, which does something at the beginning and at
the end of each connection. I found a hook to handle beginning of
connection -
ap_run_pre_connection. It's executed quite early, which works for me.
And I need to execute some actions prior or just after connection will
be closed. I looked a lot (reviewed whole connection processing - mpm,
server\connection, http module), but wasn't able to find appropriate
hook for that.
I would appreciate, if you know a method to handle that.
BTW. On note. Hooking end of request doesn't help me, because connection
could be in keepalive state, so additional requests will be served in
the same connection.
Regards,
Victor Ronin
Re: How to add referer header in external redirect?
Posted by Nick Kew <ni...@apache.org>.
On 16 Jan 2011, at 12:59, Eric Covener wrote:
>> I need some help with a redirecting/referrer issue. If I do a 303 redirect in my module (by this way below:
>> apr_table_setn(r->headers_out,"Location","http://idp/login.html");
>
> err_headers_out to be preserved when an errordoc is sent for non-2xx response.
>
Won't make any difference to someone trying to set a request header in a response.
--
Nick Kew
Available for work, contract or permanent
http://www.webthing.com/~nick/cv.html
Re: How to add referer header in external redirect?
Posted by Eric Covener <co...@gmail.com>.
2011/1/16 Whut Jia <wh...@163.com>:
> Hi all,
> I need some help with a redirecting/referrer issue. If I do a 303 redirect in my module (by this way below:
> apr_table_setn(r->headers_out,"Location","http://idp/login.html");
err_headers_out to be preserved when an errordoc is sent for non-2xx response.
Re:Re: How to add a cookie header in response headers when do
external redirect?
Posted by Whut Jia <wh...@163.com>.
Hello Eric Covener
Thank you for your answer.Your are right.
At 2011-01-17 20:41:13,"" <co...@gmail.com> wrote:
>2011/1/17 Whut Jia <wh...@163.com>:
>> Hi,
>> I want to save accessed uri into response cookie before doing a external redirect,according this way below:
>> apr_table_setn(r->headers_out,"Location","http://www.idp.com/login.jsp");
>> apr_table_setn(r->headers_out,"Set-Cookie",r->uri);
>> return HTTP_SEE_OTHER;
>> But in client ,I cannot always find cookie header in response headers ,why ?How do I solve this??
>> Thanks,
>
>r->err_headers_out?
>
>
>--
>Eric Covener
>covener@gmail.com
Re: Re: How to send a jpeg-file in Handler
Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
2011/1/19 Whut Jia <wh...@163.com>:
> Can I don't use sub-request??
> I want only a single picture to client;Just like the same as sending a text :
> r->content_type="text/html";
> ap_rputs("helloworld",r);
> return OK;
Not sure what you mean. If it's a single static image, convert it to a
C byte array and send it with ap_rwrite().
Re: Re: How to send a jpeg-file in Handler
Posted by Sorin Manolache <so...@gmail.com>.
2011/1/19 Whut Jia <wh...@163.com>:
> Hi Sorin Manolache,
> According your ways(ap_send_fd()),it is work.The picture is returned to client.But myself-set cookie content are not returned , why??
> Begin sending jpg-file,I set a cookie in headers_out :
> r->content_type="image/jpeg";
> apr_table_setn(r->headers_out,"Set-Cookie",cookie-contence);
> ap_send_fd(fd, request, 0, file_size, &bytes_sent);
> return OK;
> Besides,the request address of the jpeg picture ishttp://www.whut.com/portal/logout.jpg. This request is sent from the response page of ahttp://www.jjsonicIDP.com/saml/logout.action request .
> Thanks,
> ajxs
I don't know why the cookie is not sent.
Try apr_table_set(r->err_headers_out, ...);
Also, are you sure that the pointer to cookie_contents is still valid
at the very end of the request processing, that is _after_ you return
from the handler. If not, try apr_table_set instead of apr_table_setn.
Sorin
Re: Re: How to send a jpeg-file in Handler
Posted by Whut Jia <wh...@163.com>.
Hi Sorin Manolache,
According your ways(ap_send_fd()),it is work.The picture is returned to client.But myself-set cookie content are not returned , why??
Begin sending jpg-file,I set a cookie in headers_out :
r->content_type="image/jpeg";
apr_table_setn(r->headers_out,"Set-Cookie",cookie-contence);
ap_send_fd(fd, request, 0, file_size, &bytes_sent);
return OK;
Besides,the request address of the jpeg picture ishttp://www.whut.com/portal/logout.jpg. This request is sent from the response page of ahttp://www.jjsonicIDP.com/saml/logout.action request .
Thanks,
ajxs
At 2011-01-19 21:17:54,"Sorin Manolache" <so...@gmail.com> wrote:
>2011/1/19 Whut Jia <wh...@163.com>:
>> Can I don't use sub-request??
>> I want only a single picture to client;Just like the same as sending a text :
>> r->content_type="text/html";
>> ap_rputs("helloworld",r);
>> return OK;
>> Please help me !
>> Thanks,
>> ajxs
>>
>
>Try
>
>apr_file_t *fd;
>apr_file_open(&fd, "filename", APR_READ, 0, request->pool);
>apr_off_t file_size = 0;
>apr_file_seek(fd, APR_END, &file_size);
>apr_size_t bytes_sent;
>ap_send_fd(fd, request, 0, file_size, &bytes_sent);
>apr_file_close(fd);
>
>
>S
Re: Re: How to send a jpeg-file in Handler
Posted by Sorin Manolache <so...@gmail.com>.
2011/1/19 Whut Jia <wh...@163.com>:
> Can I don't use sub-request??
> I want only a single picture to client;Just like the same as sending a text :
> r->content_type="text/html";
> ap_rputs("helloworld",r);
> return OK;
> Please help me !
> Thanks,
> ajxs
>
Try
apr_file_t *fd;
apr_file_open(&fd, "filename", APR_READ, 0, request->pool);
apr_off_t file_size = 0;
apr_file_seek(fd, APR_END, &file_size);
apr_size_t bytes_sent;
ap_send_fd(fd, request, 0, file_size, &bytes_sent);
apr_file_close(fd);
S
Re:Re: How to send a jpeg-file in Handler
Posted by Whut Jia <wh...@163.com>.
Can I don't use sub-request??
I want only a single picture to client;Just like the same as sending a text :
r->content_type="text/html";
ap_rputs("helloworld",r);
return OK;
Please help me !
Thanks,
ajxs
At 2011-01-19 20:22:52,"Ben Noordhuis" <in...@bnoordhuis.nl> wrote:
>2011/1/19 Whut Jia <wh...@163.com>:
>> I want to return a local jpeg-file to client when client request url is /image/metto .In handler module ,I should how to write??
>
>ap_sub_req_lookup_uri() or ap_sub_req_lookup_file()?
Re: How to send a jpeg-file in Handler
Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
2011/1/19 Whut Jia <wh...@163.com>:
> I want to return a local jpeg-file to client when client request url is /image/metto .In handler module ,I should how to write??
ap_sub_req_lookup_uri() or ap_sub_req_lookup_file()?
How to send a jpeg-file in Handler
Posted by Whut Jia <wh...@163.com>.
Hi all,
I want to return a local jpeg-file to client when client request url is /image/metto .In handler module ,I should how to write??
Thanks,
ajxs.
Re: How to add a cookie header in response headers when do external redirect?
Posted by Eric Covener <co...@gmail.com>.
2011/1/17 Whut Jia <wh...@163.com>:
> Hi,
> I want to save accessed uri into response cookie before doing a external redirect,according this way below:
> apr_table_setn(r->headers_out,"Location","http://www.idp.com/login.jsp");
> apr_table_setn(r->headers_out,"Set-Cookie",r->uri);
> return HTTP_SEE_OTHER;
> But in client ,I cannot always find cookie header in response headers ,why ?How do I solve this??
> Thanks,
r->err_headers_out?
--
Eric Covener
covener@gmail.com
How to add a cookie header in response headers when do external
redirect?
Posted by Whut Jia <wh...@163.com>.
Hi,
I want to save accessed uri into response cookie before doing a external redirect,according this way below:
apr_table_setn(r->headers_out,"Location","http://www.idp.com/login.jsp");
apr_table_setn(r->headers_out,"Set-Cookie",r->uri);
return HTTP_SEE_OTHER;
But in client ,I cannot always find cookie header in response headers ,why ?How do I solve this??
Thanks,
ajxs
Re: How to add referer header in external redirect?
Posted by Ray Morris <su...@bettercgi.com>.
It's up to the browser what to send back after being redirected.
You could either a) not send a redirect header, but rather do an
internal redirect, or b) probably better would be to append the
encoded referer to the query string.
--
Ray Morris
support@bettercgi.com
Strongbox - The next generation in site security:
http://www.bettercgi.com/strongbox/
Throttlebox - Intelligent Bandwidth Control
http://www.bettercgi.com/throttlebox/
Strongbox / Throttlebox affiliate program:
http://www.bettercgi.com/affiliates/user/register.php
On Sun, 16 Jan 2011 16:32:49 +0800 (CST)
"Whut Jia" <wh...@163.com> wrote:
> Hi all,
> I need some help with a redirecting/referrer issue. If I do a 303
> redirect in my module (by this way below:
> apr_table_setn(r->headers_out,"Location","http://idp/login.html");
> return HTTP_SEE_OTHER;) In order to I can see the referrer header
> when jumping to the new page,how do I solve this??
> Thanks,
> ajxs.
>
>
>
How to add referer header in external redirect?
Posted by Whut Jia <wh...@163.com>.
Hi all,
I need some help with a redirecting/referrer issue. If I do a 303 redirect in my module (by this way below:
apr_table_setn(r->headers_out,"Location","http://idp/login.html");
return HTTP_SEE_OTHER;)
In order to I can see the referrer header when jumping to the new page,how do I solve this??
Thanks,
ajxs.
Re: Hook end of connection
Posted by Victor Ronin <vi...@gmail.com>.
On 1/12/11 4:13 PM, Andrew Godziuk wrote:
> I think the logging hook would do the trick too.
Do you mean ap_hook_log_transaction?
I believe it's executed at the end of request vs. end of connection.
Regards,
Victor
Re: Hook end of connection
Posted by Andrew Godziuk <an...@cloudaccess.net>.
I think the logging hook would do the trick too.
Re: Hook end of connection
Posted by Victor Ronin <vi...@gmail.com>.
Nick,
Thanks.
>Any cleanup registered on the child pool will run when the child quits,
>if that's any use to you.
This won't work for me (child usually serves many connection).
>Register a cleanup on the connection pool.
Got it. This will work.
Connection uses context pool and I thought initially, that it will be
cleaned only when some subsequent connection will be made. However,
I double check it now and It will be cleaned immediately when worker
will start waiting on next established connection.
Regards,
Victor
On 1/12/11 3:13 PM, Nick Kew wrote:
> On Wed, 12 Jan 2011 14:49:53 -0500
> Victor Ronin<vi...@gmail.com> wrote:
>
>> Hi,
>>
>> I need to write a module, which does something at the beginning and at
>> the end of each connection.
> Register a cleanup on the connection pool.
>
Re: Hook end of connection
Posted by Nick Kew <ni...@apache.org>.
On Wed, 12 Jan 2011 14:49:53 -0500
Victor Ronin <vi...@gmail.com> wrote:
> Hi,
>
> I need to write a module, which does something at the beginning and at
> the end of each connection.
Register a cleanup on the connection pool.
--
Nick Kew
Available for work, contract or permanent.
http://www.webthing.com/~nick/cv.html