Menu

#267 Error 404 on Cool Reader for OPDS (3rd click)

Android
pending
1
2015-11-10
2013-03-11
No

Cool Reader needs a bit more smarts put into determining the "relative path" of the opds xml links

I have setup a calibre opds, (and the HTML version is working fine, as is other ebook readers via opds)
However, on the android tablet (in Cool Reader), it shows the main page calibre OPDS page fine, and then the next click works (e.g. "tags")
but when I then choose the next one ("tags starting with z for example) I get the 404

The xml "chain" it has gone through before it fails looks like this
\Apache2.2\htdocs\opds\_catalog\index.xml
(choose "TAGS")
\Apache2.2\htdocs\opds\_catalog\ 2de82055/2de82055_tags.xml
(this shows the list of tags"
(I choose "starting with z)

I'm therefore, in this folder
\Apache2.2\htdocs\opds\_catalog\ 2de82055/
and the link says
../2de82055/2de82055_tags_5a.xml

which is effectively the same folder
This is the part where Cool Reader needs some loving. It needs to determine that it is already in that path, and strip out the redundant ../2de2055/ part because it is already in that folder.

Here are the logs showing the html access (ignoring images)
and then the xml access (cool reader opds)
(html access)
"GET /opds/_catalog/index.html HTTP/1.1" 200 35570
"GET /opds/_catalog/header.html HTTP/1.1" 200 175
"GET /opds/_catalog/2de82055/2de82055_tags.html HTTP/1.1" 200 232151
"GET /opds/_catalog/2de82055/2de82055_tags_5a.html HTTP/1.1" 200 23322

(cool reader opds access)
"GET /opds/_catalog/index.xml HTTP/1.1" 200 34396
"GET /opds/_catalog/index.xml HTTP/1.1" 200 34396
"GET /opds/_catalog//2de82055/2de82055_tags.xml HTTP/1.1" 200 233595
"GET /opds/_catalog//2de82055/2de82055/2de82055_tags_5a.xml HTTP/1.1" 404 251

If I inspect the html vs xml file, the actual link in both cases is
"../2de82055/2de82055_tags_5a.html"
so that implies that the client (web browser) is using some smarts to strip that off its' requests, whereas the android app is not.

I can provide a link to my OPDS server if required for testing, or am happy to test for you

p.s, love this app. keep up the good work

Related

Bugs: #267

Discussion

  • David Hooper

    David Hooper - 2013-04-17
    • assigned_to: nobody --> buggins
     
  • Frank de Lange

    Frank de Lange - 2014-12-10

    This bug seems to have many forms. It is probably what keeps CoolReader from working with the Owncloud OPDS catalog (https://apps.owncloud.com/content/show.php?content=168132) I made.

    CoolReader connects just fine, and shows the root page without problems. On trying to follow any of the links on that page, the results are less than perfect as it just returns 'Error occurred while reading OPDS catalog' messages. The web server log shows why:

    "GET /example/index.php/apps/files_opds//?id=directory HTTP/1.1" 200 12427 "https://www.example.org/example/index.php/apps/files_opds/" "CoolReader/3(Android)"

    The problem lies with the double slash after files_opds: files_opds//?id=directory

    This extra slash is inserted by CoolReader. Things get even stranger when the OPDS feed url is changed to remove the trailing slash:

    "GET /example/index.php/apps//?id=directory HTTP/1.1" 200 12427 "https://www.example.org/example/index.php/apps/files_opds/" "CoolReader/3(Android)"

    Now CoolReader remove the final directory, replacing it with a slash...

    The links inside the OPDS feed are relative as can be seen by this entry - the one which causes CoolReader to fail.

    <entry>
    Browse catalog
    <content type="text">Browse the catalog in alphabetical order</content>
    <link type="application/atom+xml;profile=opds-catalog;kind=navigation" href="?id=directory"/>
    <id>id:by_directory</id>
    </entry>

    May I suggest having a look at how FBReader solves this problem? Their OPDS browser has no problems browsing this feed.

     
  • Frank de Lange

    Frank de Lange - 2014-12-10

    The problem lies in the logic in OPDSUtil.java, in the LinkInfo class, in the convertHref() method:

                  public static String convertHref( URL baseURL, String href ) {
                            if ( href==null )
                                    return href;
                            String port = "";
                            if (baseURL.getPort() != 80 && baseURL.getPort() > 0)
                                    port = ":" + baseURL.getPort();
                            String hostPort = baseURL.getHost() + port;
                            if ( href.startsWith("/") )
                                    return baseURL.getProtocol() + "://" + hostPort + href;
                            if ( !href.startsWith("http://") ) {
                                    return baseURL.getProtocol() + "://" + hostPort + dirPath(baseURL.getPath()) + "/" + href;
                            }
                            return href;
    

    dirPath(baseURL.getPath()) does not work as intended, especially in combination with the extra slash which is added afterwards. Just removing that extra slash will solve the problem CoolReader has with the OPDS catalog feed from my Owncloud app, as long as the feed url was specified with a trailing slash.

     

    Last edit: Frank de Lange 2014-12-11
  • Vadim Lopatin

    Vadim Lopatin - 2014-12-11

    Thanks! Will try to fix asap.

     
  • Vadim Lopatin

    Vadim Lopatin - 2014-12-11
    • labels: OPDS --> OPDS, Android
    • status: open --> pending
    • Priority: 5 --> 1
     
  • basanas

    basanas - 2015-11-10

    Hi, is there any information we may provide to help with debugging/fixing this issue?

     
    • David Hooper

      David Hooper - 2015-11-13

      Hi,

      Here's an example of CoolReader calling the OPDS, and Moon+Reader

      You can clearly see the "relative" path that is removed by Moon+Reader (and
      other eBook clients), but not removed by CoolReader

      Coolreader

      2015-11-13 05:39:31 10.1.1.250 GET /opds/_catalog/index.xml - 80 -
      121.99.117.174 CoolReader/3(Android) 200 0 0 120

      2015-11-13 05:39:36 10.1.1.250 GET /opds/_catalog/taglist/taglist_Page_1.xml
      - 80 - 121.99.117.174 CoolReader/3(Android) 200 0 0 470

      2015-11-13 05:39:39 10.1.1.250 GET
      /opds/_catalog/taglist/taglist/taglist_Z_Page_1.xml - 80 - 121.99.117.174
      CoolReader/3(Android) 404 0 2 30

      Moon+Reader

      2015-11-13 05:43:12 10.1.1.250 GET /opds/_catalog/index.xml - 80 -
      121.99.117.174 Stanza+iPhone/Aldiko/Moon++Reader(Android) 200 0 0 140

      2015-11-13 05:43:14 10.1.1.250 GET /opds/_catalog/taglist/taglist_Page_1.xml
      - 80 - 121.99.117.174 Stanza+iPhone/Aldiko/Moon++Reader(Android) 200 0 0 230

      2015-11-13 05:43:17 10.1.1.250 GET
      /opds/_catalog/taglist/taglist_Z_Page_1.xml - 80 - 121.99.117.174
      Stanza+iPhone/Aldiko/Moon++Reader(Android) 200 0 0 140

      I can give you access to my OPDS so you can test if required, as long as you
      don't share it

      Regards,

      David

      From: basanas [mailto:basanas@users.sf.net]
      Sent: Wednesday, 11 November 2015 9:51 a.m.
      To: [crengine:bugs]
      Subject: [crengine:bugs] #267 Error 404 on Cool Reader for OPDS (3rd click)

      Hi, is there any information we may provide to help with debugging/fixing
      this issue?


      [bugs:#267] http://sourceforge.net/p/crengine/bugs/267/ Error 404 on Cool
      Reader for OPDS (3rd click)

      Status: pending
      Group: Android
      Labels: OPDS Android
      Created: Mon Mar 11, 2013 08:07 AM UTC by David Hooper
      Last Updated: Thu Dec 11, 2014 06:08 AM UTC
      Owner: Vadim Lopatin

      Cool Reader needs a bit more smarts put into determining the "relative path"
      of the opds xml links

      I have setup a calibre opds, (and the HTML version is working fine, as is
      other ebook readers via opds)
      However, on the android tablet (in Cool Reader), it shows the main page
      calibre OPDS page fine, and then the next click works (e.g. "tags")
      but when I then choose the next one ("tags starting with z for example) I
      get the 404

      The xml "chain" it has gone through before it fails looks like this
      \Apache2.2\htdocs\opds_catalog\index.xml
      (choose "TAGS")
      \Apache2.2\htdocs\opds_catalog\ 2de82055/2de82055_tags.xml
      (this shows the list of tags"
      (I choose "starting with z)

      I'm therefore, in this folder
      \Apache2.2\htdocs\opds_catalog\ 2de82055/
      and the link says
      ../2de82055/2de82055_tags_5a.xml

      which is effectively the same folder
      This is the part where Cool Reader needs some loving. It needs to determine
      that it is already in that path, and strip out the redundant ../2de2055/
      part because it is already in that folder.

      Here are the logs showing the html access (ignoring images)
      and then the xml access (cool reader opds)
      (html access)
      "GET /opds/_catalog/index.html HTTP/1.1" 200 35570
      "GET /opds/_catalog/header.html HTTP/1.1" 200 175
      "GET /opds/_catalog/2de82055/2de82055_tags.html HTTP/1.1" 200 232151
      "GET /opds/_catalog/2de82055/2de82055_tags_5a.html HTTP/1.1" 200 23322

      (cool reader opds access)
      "GET /opds/_catalog/index.xml HTTP/1.1" 200 34396
      "GET /opds/_catalog/index.xml HTTP/1.1" 200 34396
      "GET /opds/_catalog//2de82055/2de82055_tags.xml HTTP/1.1" 200 233595
      "GET /opds/_catalog//2de82055/2de82055/2de82055_tags_5a.xml HTTP/1.1" 404
      251

      If I inspect the html vs xml file, the actual link in both cases is
      "../2de82055/2de82055_tags_5a.html"
      so that implies that the client (web browser) is using some smarts to strip
      that off its' requests, whereas the android app is not.

      I can provide a link to my OPDS server if required for testing, or am happy
      to test for you

      p.s, love this app. keep up the good work


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/crengine/bugs/267/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #267


Log in to post a comment.