You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2024/11/05 11:20:19 UTC
[Bug 69430] New: ap_custom_response always overwrites an existing Content-Type Header set in r->headers_out
https://bz.apache.org/bugzilla/show_bug.cgi?id=69430
Bug ID: 69430
Summary: ap_custom_response always overwrites an existing
Content-Type Header set in r->headers_out
Product: Apache httpd-2
Version: 2.4.62
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P2
Component: Core
Assignee: bugs@httpd.apache.org
Reporter: x87@freenet.de
Target Milestone: ---
Hi,
i am working on a rest like client which returns json text. When i try to set
the Content-Type Header with:
ap_set_content_type( r, "text/json; charset=utf-8") ;
and sending the rsponse with:
ap_custom_response
(
r,
HTTP_BAD_REQUEST,
apr_pstrdup( r->pool, "{"foo": "bar"}" )
) ;
the Content-Type-Header always gets overwritten with: text/html;
charset=iso-8859-1
I have looked through the sources and found the function:
ap_send_error_response
in http_protocol.c which causes this behaviour.
When I surround the Line 1449 :
ap_set_content_type_ex(r, "text/html; charset=iso-8859-1", 1);
with an :
if ( ! apr_table_get(r->headers_out, "Content-Type") ) {
ap_set_content_type_ex(r, "text/html; charset=iso-8859-1", 1);
}
everything works fine. Do you think is's possibe to change this function, so
the Header can be set by the clients using the function: ap_custom_response
Regards
Michael
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69430] ap_custom_response always overwrites an existing Content-Type Header set in r->headers_out
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69430
--- Comment #2 from Michael.R <x8...@freenet.de> ---
Thanks for your answer, but that does not work because
ap_set_content_type_ex(r, "text/html; charset=iso-8859-1", 1);
in http_protocoll.c:1449 which finaly calls:
ap_set_content_type(r, ct);
overwrites it again.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69430] ap_custom_response always overwrites an existing Content-Type Header set in r->headers_out
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69430
--- Comment #4 from Yann Ylavic <yl...@gmail.com> ---
Hm, forget that, it still calls:
ap_set_content_type_ex(r, "text/html...", 1);
before.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69430] ap_custom_response always overwrites an existing Content-Type Header set in r->headers_out
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69430
--- Comment #5 from Michael.R <x8...@freenet.de> ---
still the same result in the response Content-Type Header: text/html...
< HTTP/1.1 400 Bad Request
< Date: Tue, 05 Nov 2024 13:07:35 GMT
< Server: Apache/2.4.62 (Unix) mod_wscmi/1.0 mod_token/1.0
< Content-Type: text/html; charset=iso-8859-1
<
{"foo": "bar"}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69430] ap_custom_response always overwrites an existing Content-Type Header set in r->headers_out
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69430
Michael.R <x8...@freenet.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |x87@freenet.de
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69430] ap_custom_response always overwrites an existing Content-Type Header set in r->headers_out
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69430
--- Comment #3 from Yann Ylavic <yl...@gmail.com> ---
And:
apr_table_unset(r->headers_out, "Content-Type");
ap_set_content_type(r, "text/json; charset=utf-8");
ap_custom_response(r, HTTP_BAD_REQUEST,
apr_pstrdup(r->pool, "\"{\"foo\": \"bar\"}"));
?
Note the new leading \" in the json, this is what's expected (and skipped) by
ap_send_error_response() to send plain text straight away.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69430] ap_custom_response always overwrites an existing Content-Type Header set in r->headers_out
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69430
--- Comment #1 from Yann Ylavic <yl...@gmail.com> ---
Possibly:
apr_table_unset(r->headers_out, "Content-Type");
ap_set_content_type(r, "text/json; charset=utf-8");
would do?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69430] ap_custom_response always overwrites an existing Content-Type Header set in r->headers_out
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69430
--- Comment #6 from abernal <ab...@apache.org> ---
Proposed fix: https://github.com/apache/httpd/pull/866
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org