@@ -19,7 +28,7 @@ print("\n")
- This page is an Atom 1.0 feed. The URL in your browser’s address bar () can be used in any Atom client.
+ This page is an Atom 1.0 feed. The URL in your browser’s address bar () can be used in any Atom client. If you’re prompted to authenticate, enter the email address you used to join the Patrons Circle and a blank password.
-
diff --git a/www/feeds/download.php b/www/feeds/download.php
index 05f05487..bc27581e 100644
--- a/www/feeds/download.php
+++ b/www/feeds/download.php
@@ -54,20 +54,49 @@ try{
// Much more efficient than reading it in PHP and outputting it that way.
header('X-Sendfile: ' . WEB_ROOT . $path);
- if(preg_match('/^\/feeds\/opds/', $path)){
- header('Content-Type: application/atom+xml;profile=opds-catalog;kind=acquisition; charset=utf-8');
+ $http = new HTTP2();
+ $mime = 'application/xml';
- if(preg_match('/\/index\.xml$/', $path)){
- header('Content-Type: application/atom+xml;profile=opds-catalog;kind=navigation; charset=utf-8');
+ // Decide on what content-type to serve via HTTP content negotation.
+ // If the feed is viewed from a web browser, we will usuall serve application/xml as that's typically what's in the browser's Accept header.
+ // If the Accept header has application/rss+xml or application/atom+xml then serve that instead, as those are the
+ // "technically correct" content types that may be requested by RSS readers.
+ if(preg_match('/^\/feeds\/opds/', $path)){
+ $contentType = [
+ 'application/atom+xml',
+ 'application/xml',
+ 'text/xml'
+ ];
+ $mime = $http->negotiateMimeType($contentType, 'application/atom+xml');
+
+ if($mime == 'application/atom+xml'){
+ if(preg_match('/\/index\.xml$/', $path)){
+ $mime .= ';profile=opds-catalog;kind=navigation; charset=utf-8';
+ }
+ else{
+ $mime .= ';profile=opds-catalog;kind=acquisition; charset=utf-8';
+ }
}
}
elseif(preg_match('/^\/feeds\/rss/', $path)){
- header('Content-Type: application/rss+xml');
+ $contentType = [
+ 'application/rss+xml',
+ 'application/xml',
+ 'text/xml'
+ ];
+ $mime = $http->negotiateMimeType($contentType, 'application/rss+xml');
}
elseif(preg_match('/^\/feeds\/atom/', $path)){
- header('Content-Type: application/atom+xml');
+ $contentType = [
+ 'application/atom+xml',
+ 'application/xml',
+ 'text/xml'
+ ];
+ $mime = $http->negotiateMimeType($contentType, 'application/atom+xml');
}
+ header('Content-Type: ' . $mime);
+
exit();
}
catch(Exceptions\LoginRequiredException){
diff --git a/www/feeds/opds/style.php b/www/feeds/opds/style.php
index ff18768f..e8fd0709 100644
--- a/www/feeds/opds/style.php
+++ b/www/feeds/opds/style.php
@@ -1,8 +1,17 @@
require_once('Core.php');
-// `text/xsl` is the only mime type recognized by Chrome for XSL stylesheets
-header('Content-Type: text/xsl; charset=utf-8');
+$http = new HTTP2();
+
+$contentType = [
+ 'application/xslt+xml',
+ 'application/xml',
+ 'text/xml'
+];
+
+$mime = $http->negotiateMimeType($contentType, 'application/xslt+xml');
+
+header('Content-Type: ' . $mime . '; charset=utf-8');
print("\n")
?>
@@ -19,7 +28,7 @@ print("\n")
- This page is an OPDS 1.2 feed. The URL in your browser’s address bar () can be used in any OPDS client.
+ This page is an OPDS 1.2 feed. The URL in your browser’s address bar () can be used in any OPDS client. If you’re prompted to authenticate, enter the email address you used to join the Patrons Circle and a blank password.