kohabug 2078 - send correct Content-type for search feeds
OPAC search RSS and ATOM feeds now have the correct Content-type sent - "application/rss+xml" and "application/atom+xml", respectively. As part of this patch, added an optional fourth parameter to C4::Output::output_html_with_http_headers to specify the content type. If that parameter is now supplied, or if the value of the parameter does not contain at least a "/", the default type of "text/html" is returned. No documentation changes. Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
parent
1a41d12a96
commit
8fc6b927df
17
C4/Output.pm
17
C4/Output.pm
|
|
@ -35,7 +35,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
|
|||
|
||||
BEGIN {
|
||||
# set the version for version checking
|
||||
$VERSION = 3.02;
|
||||
$VERSION = 3.03;
|
||||
require Exporter;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT_OK = qw(&output_ajax_with_http_headers &is_ajax); # More stuff should go here instead
|
||||
|
|
@ -342,18 +342,25 @@ sub pagination_bar {
|
|||
|
||||
=item output_html_with_http_headers
|
||||
|
||||
&output_html_with_http_headers($query, $cookie, $html)
|
||||
&output_html_with_http_headers($query, $cookie, $html[, $content_type])
|
||||
|
||||
Outputs the HTML page $html with the appropriate HTTP headers,
|
||||
with the authentication cookie $cookie and a Content-Type that
|
||||
corresponds to the HTML page $html.
|
||||
|
||||
If the optional C<$content_type> parameter is called, set the
|
||||
response's Content-Type to that value instead of "text/html".
|
||||
|
||||
=cut
|
||||
|
||||
sub output_html_with_http_headers ($$$) {
|
||||
my($query, $cookie, $html) = @_;
|
||||
sub output_html_with_http_headers ($$$;$) {
|
||||
my $query = shift;
|
||||
my $cookie = shift;
|
||||
my $html = shift;
|
||||
my $content_type = @_ ? shift : "text/html";
|
||||
$content_type = "text/html" unless $content_type =~ m!/!; # very basic sanity check
|
||||
print $query->header(
|
||||
-type => 'text/html',
|
||||
-type => $content_type,
|
||||
-charset => 'UTF-8',
|
||||
-cookie => $cookie,
|
||||
-Pragma => 'no-cache',
|
||||
|
|
|
|||
|
|
@ -577,4 +577,7 @@ if ( C4::Context->preference("kohaspsuggest") ) {
|
|||
}
|
||||
|
||||
# VI. BUILD THE TEMPLATE
|
||||
output_html_with_http_headers $cgi, $cookie, $template->output;
|
||||
my $content_type = $cgi->param('format') =~ /rss/ ? "application/rss+xml" :
|
||||
$cgi->param('format') =~ /atom/ ? "application/atom+xml" :
|
||||
"text/html";
|
||||
output_html_with_http_headers $cgi, $cookie, $template->output, $content_type;
|
||||
|
|
|
|||
Loading…
Reference in New Issue