You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/10/29 01:47:27 UTC

[jira] [Commented] (COUCHDB-1852) Last-Event-ID header should be honoured in eventsource _changes feed

    [ https://issues.apache.org/jira/browse/COUCHDB-1852?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14979571#comment-14979571 ] 

ASF GitHub Bot commented on COUCHDB-1852:
-----------------------------------------

Github user kxepal commented on a diff in the pull request:

    https://github.com/apache/couchdb/pull/354#discussion_r43337892
  
    --- Diff: test/javascript/tests/changes.js ---
    @@ -638,29 +664,36 @@ couchTests.changes = function(debug) {
       req = CouchDB.request("GET", "/" + db.name + "/_changes?style=all_docs");
       resp = JSON.parse(req.responseText);
     
    -  TEquals(3, resp.last_seq);
    +  // (seq as before)
    +  //TEquals(3, resp.last_seq);
       TEquals(2, resp.results.length);
     
    -  req = CouchDB.request("GET", "/" + db.name + "/_changes?style=all_docs&since=2");
    +  // we can no longer pass a number into 'since' - but we have the 2nd last above - so we can use it (puh!)
    +  req = CouchDB.request("GET", "/" + db.name + "/_changes?style=all_docs&since=" + encodeURIComponent(JSON.stringify(resp.results[0].seq)));
       resp = JSON.parse(req.responseText);
     
    -  TEquals(3, resp.last_seq);
    +  // (seq as before)
    +  //TEquals(3, resp.last_seq);
       TEquals(1, resp.results.length);
       TEquals(2, resp.results[0].changes.length);
     
       // COUCHDB-1852
    -  T(db.deleteDb());
    +  // test w/ new temp DB
    +  db_name = get_random_db_name();
    +  db = new CouchDB(db_name, {"X-Couch-Full-Commit":"true"});
       T(db.createDb());
     
    -  // create 4 documents... this assumes the update sequnce will start from 0 and get to 4
    +  // create 4 documents... this assumes the update sequnce will start from 0 and then do sth in the cluster 
       db.save({"bop" : "foom"});
       db.save({"bop" : "foom"});
       db.save({"bop" : "foom"});
       db.save({"bop" : "foom"});
    +  // because of clustering, we need the 2nd entry as since value
    +  req = CouchDB.request("GET", "/" + db_name + "/_changes");
     
       // simulate an EventSource request with a Last-Event-ID header
    -  req = CouchDB.request("GET", "/test_suite_db/_changes?feed=eventsource&timeout=0&since=0",
    -        {"headers": {"Accept": "text/event-stream", "Last-Event-ID": "2"}});
    +  req = CouchDB.request("GET", "/" + db_name + "/_changes?feed=eventsource&timeout=0&since=0",
    +        {"headers": {"Accept": "text/event-stream", "Last-Event-ID": JSON.stringify(JSON.parse(req.responseText).results[1].seq)}});
    --- End diff --
    
    See https://github.com/apache/couchdb-chttpd/pull/89 . I made this value completely opaque as it was before, so there is no need to JSON encode seq for Last-Event-ID header. However, we can discuss this moment.


> Last-Event-ID header should be honoured in eventsource _changes feed
> --------------------------------------------------------------------
>
>                 Key: COUCHDB-1852
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1852
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>            Reporter: Damjan Georgievski
>             Fix For: 1.4.0
>
>         Attachments: 0001-add-test-for-COUCHDB-1852.patch, 0002-Fix-for-COUCHDB-1852.patch
>
>
> When using the EventSource _changes feed support, the browser API will automatically reconnect and send the last sequence it received in the Last-Event-ID header.
> The server side needs to use the Last-Event-ID instead of the 'since' query string as a starting point for the changes feed.
> You can see the issue by simply creating a database and adding documents and watching what happens to the eventsource _changes feed.
> To see the feed with curl use:
> {{curl -i -H 'Last-Event-ID: 2' 'http://localhost:5984/testdb/_changes?feed=eventsource'}}
> the header should also have priority over the since query string:
> {{curl -i -H 'Last-Event-ID: 2' 'http://localhost:5984/testdb/_changes?feed=eventsource?since=1'}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)