Giter VIP home page Giter VIP logo

Comments (4)

martinsumner avatar martinsumner commented on August 16, 2024

This may be all related to underlying assumptions of webmachine, and the flow chart that webmachine will go through.

Functionality such as if_none_match and if_match are included in the standard webmachine flow. However, that standard flow requires the stage G7 "Resource Exists" to be passed for both GET and POST. If we bypass the check for resource existence, we may well bypass inherent features for conditional handling of HTTP headers.

Some features that may have to be handled explicitly in the PB API, may be handled implicitly by webmachine.

from riak_kv.

martinsumner avatar martinsumner commented on August 16, 2024

The riak_kv_wm_object module has to cover both GET, PUT and DELETE. Reviewing the code, there are some tricky issues for these flows.

On the GET path, one issue is that the content-type of an object returned, should be the content-type of the object which was used when it was PUT.

The natural place to fetch the resource in the webmachine flow is v3g7 - resource_exists/2. However, this only occurs after validation, including validation of the encoding the client says it will accept. However, the inbound Accept-Encoding on the request cannot be validated until the object has been fetched (and we know what content-type it is to be presented back as).

To try and ensure this works there is an ensure_doc/2 functions that does the GET, only if there is not an object (i.e doc) already on the context. This ensure_doc/2 is then called in its natural place on resource_exists/2, but also at any validation stage that may require knowledge of the content returned from the fetch. The ensure_doc/2 means the GET only occurs once, when ever information about the document is first needed.

Some of the exportable functions needed in validation such as encodings_provided are also required as part of the PUT path (e.g. to return_body). these functions may be called either before or after resource_exists on both GET and PUT. therefore we cannot simply ignore this when the method is PUT/POST.

from riak_kv.

martinsumner avatar martinsumner commented on August 16, 2024

For DELETE, the same initial path in webmachine applied as for GET. This means that DELETE will also try and GET the resource prior to calling riak_client:delete/4 or riak_client:delete_vclock/4.

This means a further unnecessary GET, but also means that {error, notfound} is treated as a failure - whereby on the PB API {error, notfound} leads to a positive response, on the basis that the object is not there (even though it not being there is potentially unexpected).

from riak_kv.

martinsumner avatar martinsumner commented on August 16, 2024

Replacing with #1849.

This issue misunderstands the workings of webmachine. The problem is better explained in kv1849.

from riak_kv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.