energywebfoundation / ocn-node

Apache License 2.0
5 stars 4 forks source link

Pagination response header "Link" should encode the parameters of the next request #10

Open ewf-devops opened 4 years ago

ewf-devops commented 4 years ago

Original report by Adam Staveley (Bitbucket: [Adam Staveley](https://bitbucket.org/Adam Staveley), GitHub: adamstaveley).


When receiving a “proxied” pagination response “Link” header, i.e. Link: <https://node.ocn.net/ocpi/sender/2.2/locations/page/2>; rel=”next”, the recipient receives no information in the URL about the url-encoded parameters which will be used in the next request.

As an example, if the sender requests https://node.ocn.net/ocpi/sender/2.2/locations?offset=50 the response header should contain the values set by the recipient.

Therefore, a header Link: <https://server.cpo.com/ocpi/sender/2.2/locations?offset=100>; rel=”next” should be converted by the OCN Node to Link: <https://node.ocn.net/ocpi/sender/2.2/locations/page/3?offset=100>; rel=”next”.

ewf-devops commented 4 years ago

Original comment by John Henderson (Bitbucket: [John Henderson](https://bitbucket.org/John Henderson), GitHub: jrhender).


@{5efc3c2c54020e0ba82c6e64} I’m trying to understand this bug a little better. What do you mean by “url-encoded parameters”? Do you mean the route/path components (e.g. the page/3 component from the example that you gave in the issue description) ?

ewf-devops commented 4 years ago

Original comment by Adam Staveley (Bitbucket: [Adam Staveley](https://bitbucket.org/Adam Staveley), GitHub: adamstaveley).


So the url parameters like ?limit=50&offset=100 which are set by the recipient of a paginated request, are not sent back to the sender. They receive the resource proxied by the OCN Node (parameters are replaced with /page/n). They therefore have no idea what they are requesting on the next page (i.e. the offset, the request limit, the total number of resources).