Git Product home page Git Product logo

http-decision-diagram's Introduction

http-decision-diagram

An activity diagram to describe the resolution of HTTP response status codes, given various headers, implemented via semantical callbacks.

And it goes on Twitter as #httpdd - HTTP Decision Diagram.

This is part of a bigger effort: for-GET HTTP.

The diagram follows the indications in RFC7230 RFC7231 RFC7232 RFC7233 RFC7234 RFC7235, and fills in the void where necessary. Under no circumstances does this diagram override the HTTP specifications. If it does, please file an issue as soon as possible.

The diagram is also available in PNG/JPEG/SVG and JSON format exported from the Cosmogol source. See the documentation here.

HTTP headers status


cache-retrieve and cache-store

Darrel Miller started something similar to HTTP decision diagram, in terms of deciding whether to cache (store) or not a HTTP response, and whether to respond to a HTTP request with a cached HTTP response or not.

The cache-retrieve diagram is available in PNG/JPEG/SVG and JSON format exported from the Cosmogol source.

The cache-store diagram is available in PNG/JPEG/SVG and JSON format exported from the Cosmogol source.


License

Apache 2.0

Stargazers over time

Stargazers over time

http-decision-diagram's People

Contributors

andreineculau avatar liyishuai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

http-decision-diagram's Issues

Question regarding PATCH support

I'm working with @seancribbs to add PATCH support to webmachine, and he suggested I look at this project for a guide. If someone could answer a question for me, I'd greatly appreciate it.

Is PATCH fully supported by the current design? I can see Accept-Patch headers specified, which suggests it is at least partially supported, but reading the HTTP spec for PATCH tells me that I should be able to get a 409 response when using PATCH, and I cannot see in the current flow how that could happen - I'm assuming that we would follow true at is_method_create and is_method_process, however there is no flow after that that can take us to a 409 like there is for PUT.

201 Created is missing?

Where is says is_process_done -> 202 Accepted

I think it should split, if the operation could be complemented within the request lifetime it should lead to a 201 Created, if it accepted for future processing, then yes, 202 Accepted.

Content negotiation can mask more appropriate errors

We actually had this happen at some point with a Webmachine server:

  1. Client sent 'Accept: application/json' with a 'GET /foo'.
  2. /foo doesn't exist, but the standard 404 error message wants to have a 'text/html' body.
  3. Client gets sent a 406 (Not Acceptable) instead of the 404 that would be more accurate/useful and less surprising.

Proposed solution: have a hook for error message generation to generate an acceptable media type for them, or to omit a body on the error if such an acceptable media type doesn't exist.

Omits 428 Precondition Required

Nice diagram.
The flow does not specify checks for required preconditions (If-Match required) and the 428 response if omitted.

Override some HTTP statuses

Some HTTP statuses may leak out information, so it's better to alter them.

While one can do so in override, maybe there should be a more specific way to override statuses just from the perspective of leaking out information.

representation exists

Thanks to @mootboy @kvakvs @sstrigler - a possible enhancement popped up today - the retrieve:missing callback checks if the resource is missing, but not if the representation is missing, which is what 404 is supposed to check against.

alternatives:

  • leave it as today = leave the content type handler to decide whether to force a 404
  • introduce a missing_representation callback; where? not sure

query definition

query params should be defined somehow via a callback, in order to produce uri templates (when adding link support), or when responding to OPTIONS

Purpose of content_types_accepted and content_types_provided handlers

Like #3 states, content_types_provided:handler is only called for GET/HEAD/PUT but not for POST.

Similarly, as https://github.com/basho/webmachine/issues/122 states, content_types_accepted:handler is only called for POST when post_is_create is true, and for PUT when is_conflict is false, but not for regular POST

Proposed resolution
content_types_accepted:handler should be called uniformly, regardless of the invoked HTTP method, right about where known_content_type is called. If it's known, then handle it (ie. translate it to Context)
content_types_provided:handler should be called uniformly, regardless of the flow (method, status code) IF there is a Content-Type response header set, and has_resp_body is false, right after webmachine_decision_core:respond handles the logic for HTTP status codes & headers.

How to deal with 404?

Am I right in understanding that 404 should be dealt with before entering the system block? So in effect, there's a decision to be made before entering the decision state machine, of whether or not to enter it in the first place?

Review PATCH/409

Food for thought:

  • leave the catch-all for non RFC2616 methods
  • add conflict/409 check for PATCH just like for PUT
  • extract the create/process block into a "standalone" FSM

Ref: #35 (comment)

malformed_request

I can only think of using this callback for checking against known deserializers, eg. is this application/json or application/...+json, then check if this is valid JSON.

But

  • why check for valid syntax, if this is maybe not a known_media_type (b5 - 415 Unsupported Media Type?
  • http://stackoverflow.com/a/12891726/465684 400 is supposed to incorporate 422 Unprocessable Entity, thus one has to also check if the message makes sense (ie. validate against JSON Schema, validate logical rules)

Proposed resolution
Check for known_media_type before malformed_request

Printer-friendly version

This diagram is amazing!

Any chance of arranging it slightly for a more printer-friendly version? It belongs in a frame!

Path to 400 Bad Request on POST creation

This is a question about understanding the path (i.e. the logical flow) to generate a 400 Bad Request when creating a resource via POST. (Note: I've referred to the Omnigraffle document in writing this; if it is not up-to-date, I would be missing some new information.)

First, I want to mention some relevant creation (i.e. the "create" section) behaviors from the decision diagram:

  • If create_partial_put is false then respond with 400 Bad Request. (This seems reasonable to me.)
  • If create_has_conflict is true then respond with 409 Conflict. (This seems reasonable to me.)
  • If create_path is false then respond with 500 Internal Server Error. (But I don't the meaning of create_path; see #43)
  • If create is false, then respond with 500 Internal Server Error. (This seems reasonable; however, what about client errors? More on this next.)

It seems pretty clear that resource creation must happen in create. But as I show above, if a POST resource creation fails, the decision diagram does not provide an opportunity for a 400 Bad Request response.

Next, I want to figure out where client validation should take place in order to generate a 400. If what I've written above is accurate, then resource validation must happen before the "create" block. So, looking around, there are only two prior checks that can result in 400 Bad Request: from_content and is_request_block_ok.

  • I see that from_content will not run if has_content is false, therefore it would be possible for a malformed client POST to bypass it. Therefore, this does not seem like a smart place to put validation logic for a POST body.
  • By the process of elimination, is_request_block_ok would be the place to validate a POST payload.

Is my logic accurate? Did I miss anything?

Now, an opinion: if I'm right, it seems unfortunate that is_request_block_ok is the correct place to do POST payload validation since it happens so much later in the decision diagram. I would expect POST-related logic to be 'closer' together.

For the point of argument, why not make a POST request's payload processing happen during the 'create' block? That would offer the advantage of letting the 'accept' block run beforehand -- why do the creation if the acceptance criteria are not met?

CORS support

CORS is rather common
process_options : in should call specific callbacks for setting access-control-* headers

What does create_path mean?

I don't understand the context or purpose of it. Thanks in advance for helping me understand.

P.S. I presume that create is where the actual resource creation would/should happen. Since create_path happens immediately before, I though that would be enough of a clue to figure it out, but I'm still unsure.

error block -> alternative block

#23 implies creating a block similar to the error block where one would do conneg on a specific set of provided MTs, just that instead of errors, we now want to communicate choices

Add decision point references to README

The questions listed in the v4 readme would be easier to follow if the decision point references (f4, i14, n14 etc.) from the v4 draft were included for each question - these questions then serve as a slightly more detailed explanation of those points than is given on the flow chart image.

forbidden

Similarly to #1 , how can one check if the request forbidden before even checking if this is a known_media_type?

Proposed resolution
Check for known_media_type before forbidden

why check for unknown/unsupported Content-* headers ?

I cannot find anything pointing to this check in the RFC, and if I think about it.. there are other reasons why a 501 Not Implemented can be triggered e.g. Expect request header

I'm thinking of removing this check in favour of the "bucket" is_request_ok which can catch anything.

@adean any input?

Where should body and headers be set?

Webmachine decision core and the resource callbacks (can) set headers almost anywhere, which easily leads to headers being set for HTTP status codes where they don't make sense, eg. https://github.com/basho/webmachine/issues/114

Proposed resolution
Mark possible headers as meta-data, and only set a subset of those as response headers at the end of the request processing flow ie. webmachine_decision_core:respond and finish_request resource callback. This would make respond and finish_request encapsulate logic around the HTTP status codes..

It is not clear what is part of RFC(s) and what is not

As stated in #8 (comment) the v3 decision diagram was created to reflect RFC 2616.

It should be visible what is, and what is not part of RFC 2616, httpbis, any other RFC.

visible may not mean "on the diagram" (in order not to overload it), but options should be investigated into at least marking the non-RFC-extensions on the diagram image file

why i7 moved?

What is the idea behind the decision branch i7 moved? As best as I can tell, it serves only as a possible short-circuit for skipping the next decisions moved_permanently, moved_temporarily, gone_permanently.

301&302 vs 307&308

given 307 & 308, is there a good reason beyond “legacy” compatibility to support 301 & 302?

the diagram went KISS and chose 307 & 308 in 49cc4b7

handle links

transaction also needs to handle links, at a basic level for #23 to be fully completed

dispatch uri vs resource uri

the resource should probably be self-aware of the path it is instantiated on, otherwise it's impossible for it to produce a response with a rel=self link

it could also just call the dispatcher, which would search in the dispatch config for a resource match, but if the resource is served from multiple locations, then which is the canonical location?

temp idea: canonical_uri callback

link on diagram

the link has an incorrect link to the old repository of this code (http-headers-status)

missing_has_precondition

What should missing_has_precondition be checking? There's no documentation for it yet, and no implementation in for-GET/machine.

Automatic `known_content_type` ?

Like https://github.com/basho/webmachine/issues/123 states, known_content_type is independent from content_types_accepted.

This is rather confusing, and it doesn't have an obvious benefit: why/how can the resource know more content-types than it accepts and handles?

Proposed resolution
Remove the known_content_type callback, and make the decision based on inspecting the output of content_types_accepted

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.