Help: HTTP response has wrong Content-Type field
Help: HTTP response has wrong Content-Type field
am 24.10.2009 02:59:07 von HE Hongmei
We developed an Apache module. In the module, when we sent HTTP
response, Apache always changed the "Content-Type", sometimes this field
is correct, sometime it is truncated, sometimes with an invalid value.
We sent response back with the following function, and the response
header was always set properly.
int our_module_handler(request_rec *r)
{
// process requests=20
// prepare response
ap_set_content_type(r, "application/user-config+xml");
ap_send_http_header(r);
ap_rwrite(..);
return OK;
}
We added some logs before and after the above calls, and found the
content-type is always right. However, sometimes (not always), in the
response sent by Apache server, Content-Type will be changed to
something like "application/user-config" or
"application/user-config+xm", or some other values.
We are using MPM worker module. We tried Apache 2.2.8 and 2.2.14, both
of the versions had the problem. We can not determined that it is Apache
issue. If anyone ever encountered similar issue, we are very appreciated
your response.
Thanks.
Hongmei
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Help: HTTP response has wrong Content-Type field
am 24.10.2009 03:12:54 von Eric Covener
On Fri, Oct 23, 2009 at 8:59 PM, HE Hongmei
wrote:
>
> We added some logs before and after the above calls, and found the
> content-type is always right. However, sometimes (not always), in the
> response sent by Apache server, Content-Type will be changed to
> something like "application/user-config" or
> "application/user-config+xm", or some other values.
I suspect its your modules own misuse of r->pool. Completely gut all
of your actual logic from your module and see if it still truncates
the header.
Or start with a new module that just sets the content type and prints
a canned response.
--
Eric Covener
covener@gmail.com
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: Help: HTTP response has wrong Content-Type field
am 24.10.2009 14:49:10 von HE Hongmei
Thank you very much for the response.=20
We finally got the root cause. When we used the following code to set
content type, there will be problem. The reason is that Apache
ap_set_content_type does not copy the content to
request_rec::content_type, it only use the "const char*" pointer. When
our_module_handler returns, the pointer is released, so some strange
data is in content_type, and put back to HTTP response. We resolved it
by defining some "const char*" variables and set with them when calling
ap_set_content_type.
int our_module_handler(request_rec *r)
{
....
String data=3D""
ap_set_content_type(r, data.c_str());
....
}
Hongmei=20
-----Original Message-----
From: Eric Covener [mailto:covener@gmail.com]=20
Sent: Saturday, October 24, 2009 9:13 AM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Help: HTTP response has wrong Content-Type
field
On Fri, Oct 23, 2009 at 8:59 PM, HE Hongmei
wrote:
>
> We added some logs before and after the above calls, and found the=20
> content-type is always right. However, sometimes (not always), in the=20
> response sent by Apache server, Content-Type will be changed to=20
> something like "application/user-config" or=20
> "application/user-config+xm", or some other values.
I suspect its your modules own misuse of r->pool. Completely gut all of
your actual logic from your module and see if it still truncates the
header.
Or start with a new module that just sets the content type and prints a
canned response.
--
Eric Covener
covener@gmail.com
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server
Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org