httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kiffin Gish" <Kiffin.G...@tomtom.com>
Subject Re: ap_custom_response content type 'text/xml'
Date Thu, 26 Jun 2008 13:48:53 GMT
Thanks Brian, I've tried what you suggested but it doesn't seem to work.
Could you be more specific? Here's what I've tried:

void register_hooks(apr_pool_t *p)
{
    ap_hook_translate_name(hook_translate_name, NULL, NULL,
APR_HOOK_REALLY_FIRST);
    ap_hook_pre_connection(hook_pre_connection, NULL, NULL,
APR_HOOK_MIDDLE);
    ap_register_output_filter("wms-error-http-header", wmserror_ofilter,
	    NULL, AP_FTYPE_CONNECTION) ;
}

static int hook_translate_name (request_rec *r)
{
    apr_table_setn(r->notes, "MY_NOTE", ".");
    ap_custom_response(r, HTTP_INTERNAL_SERVER_ERROR, xml);
    return HTTP_INTERNAL_SERVER_ERROR;
}

static int hook_pre_connection(conn_rec *c, void *csd)
{
    ap_add_output_filter("wms-error-httpd-header", NULL, NULL, c);
    return OK;
}

int wmserror_ofilter(ap_filter_t* f, apr_bucket_brigade* bb)
{
    const char *t = apr_table_get(f->r->notes, "MY_NOTE");
    if (t != NULL) { ap_set_content_type(f->r, "text/xml"); }
    return ap_pass_brigade(f->next, bb) ;
}

On Thu, 2008-06-26 at 08:35 -0400, Brian J. France wrote:
> On Jun 26, 2008, at 3:33 AM, Kiffin Gish wrote:
> > In order to reply with my own xml error, I want to use
> > ap_custom_response(r, HTTP_INTERNAL_SERVER_ERROR, xml);
> >
> > However, default content type is "text/html". If I try to change it by
> > using ap_set_content_type(r, "text/xml"), this has no effect.
> >
> > Is there anyone out there who can help me?
> >
> 
> Ran into the same thing with apache 1.3.  We have a patch that adds a  
> custom hook that is called before headers are sent and we can re-set  
> it back to text/xml there (remember this is 1.3).
> 
> You could call ap_custom_response, set a flag in r->notes, have a  
> output filter in your module that checks r->notes and if the flag set  
> it scans for Content-type and resets it to text/xml.
> 
> Brian
> 
-- 
Kiffin Gish | Desktop & Services Development | TomTom | kiffin.gish@tomtom.com | +31 (0)
6 15529214 mobile | +31 (0) 20 757 5000 office

Mime
View raw message