Coder Social home page Coder Social logo

zotonic / webzmachine Goto Github PK

View Code? Open in Web Editor NEW
11.0 10.0 9.0 1.16 MB

Zotonic's fork of Basho's webmachine

Home Page: http://zotonic.com/

License: Apache License 2.0

Erlang 65.84% Shell 0.15% CSS 2.27% JavaScript 6.25% Makefile 0.25% HTML 25.25%

webzmachine's Issues

Error documents should only be used when text/html is accepted

We now send a HTML error document, even when the content type of the controller will be something different.

We also don't check what the user agent accepts.

Maybe it is possible to determine the probable content type by calling content_types_provided and check it against the accept headers.

That is just like steps v3c3 and v3c4 in the webmachine_decision_core.erl

doc

do you have any doc somewhere documenting changes? how is Orking the websocket handling? ( i assume your wm could be used alone)

Disentangle Content-Encoding, Transfer-Encoding, character set conversion and chunked transfers.

In Webmachine there is a bit confusion between Content-Encoding and Transfer-Encoding.

The Content-Encoding is applied by functions, though also on the chunks. This doesn't play well with gzip, as that should be applied to the whole entity and not to its chunks.

The idea behind Content-Encoding is that the server has multiple versions of an entity, and can select which version should be served. That means that the server has already a prepared compressed version of the data. The Range is also applied on this (compressed) version of the data.

The Transfer-Encoding is applied after the fetching the correct ranges and can consists of chunking or (further) compression. There can be multiple Transfer-Encodings, they are given in the header in the order that they were applied. For example, first chunking and then gzip will give:

Transfer-Encoding: chunked, gzip

This plays well with different content encodings.

In this way there will be a clear distinction: the controller provides the content and Webzmachine might add transfer encodings.

On a similar note, the character set is almost always UTF-8 and should be supplied by the content, i.e. not changed by Webzmachine.

I propose to add two new callbacks, remove one, and change another:

New:

  • content_encodings_provided/2
  • transfer_encodings_provided/2

Remove:

  • encodings_provided/2

Change return format of:

  • charsets_provided/2

All three will return a list of encodings/charsets, instead of tuples with the encoding and re-code functions.

The content_types_provided/2 function should then take the selected charset and encoding to select the correct content function (or the content function can handle that).

The selected encodings are available from:

  • webmachine_request:get_metadata('content-encoding', ReqData)
  • webmachine_request:get_metadata('chosen-charset', ReqData)
  • webmachine_request:get_metadata('content-type', ReqData)

Handling of {error, closed} missing in recv_unchunked_body

10:31:24.416 [error] webmachine error: path="/postback": {error,{error,{badmatch,{error,closed}},[{webmachine_request,recv_unchunked_body,3,[{file,"src/webmachine_request.erl"},{line,524}]},{webmachine_request,do_recv_body,1,[{file,"src/webmachine_request.erl"},{line,488}]},{webmachine_request,req_body,2,[{file,"src/webmachine_request.erl"},{line,736}]},{wrq,req_body,1,[{file,"src/wrq.erl"},{line,135}]},{controller_postback,process_post_ubf,2,[{file,"modules/mod_base/controllers/controller_postback.erl"},{line,60}]},{webmachine_controller,controller_call,3,[{file,"src/webmachine_controller.erl"},{line,209}]},{webmachine_decision_core,decision,3,[{file,"src/webmachine_decision_core.erl"},{line,484}]},{webmachine_decision_core,handle_request,2,[{file,"src/webmachine_decision_core.erl"},{line,31}]}]}}

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.