Giter Site home page Giter Site logo

Comments (12)

andrewgodwin avatar andrewgodwin commented on May 22, 2024

Do you mean inbound transfer encoding, or outbound? I presume you mean inbound, given you mentioned request.

My stance on this is that it's up to the framework to handle it, as the ASGI spec does not have high-level-enough messages in the HTTP extension to handle this - but it will give the framework the request body as it arrives, allowing it to be done there. This also reflects how WSGI handled it (which is to say, it didn't).

from asgiref.

davidism avatar davidism commented on May 22, 2024

WSGI servers ended up being the ones that handled decoding. In ASGI the distinction is clearer and it possibly makes sense for the app to handle it. Would be nice if there was a sans-io library for this, maybe there is already.

from asgiref.

tomchristie avatar tomchristie commented on May 22, 2024

Uvicorn automatically uses Transfer-Encoding: chunked For streaming response with no Content-Length set. I’ve not double checked Daphne or Hypercorn’s behaviour. I’d generally assume(?) that it makes sense that way, since it’s a required level of baseline functionality for streaming responses, and there’s no real value in forcing that onto framework-level implementations.

from asgiref.

stuxcrystal avatar stuxcrystal commented on May 22, 2024

I think it'd be good if the ASGI-spec could explicitly define who is responsible for handling Transfer-Encoding. Otherwise, I think, nobody will implement it or worse: Both will handle it, mangling the incoming message.

from asgiref.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

Outbound/response chunked encoding should be handled by servers, as it is in WSGI - I believe this is what @tomchristie is referring to. For inbound chunked encoding, I think it should be applications, if they wish. I will make a PR that clarifies this.

from asgiref.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

OK, so I have whipped up a PR for the current situation (#96), but I'm not super thrilled about having things be so asymmetric - application-handled inbound, and server-handled outbound. Are there any advantages to doing it this way? Or should we have the servers handle the transfer-encoding overhead? (Especially as it's only for single hops, so there's no guarantee a reverse proxy isn't getting rid of it)

from asgiref.

davidism avatar davidism commented on May 22, 2024

Transfer encoding doesn't really strike me as an application-level concern, so if it's reasonable for the server to handle decoding and encoding, that seems preferable.

from asgiref.

tomchristie avatar tomchristie commented on May 22, 2024

I think that chunked transfer encoding (which can be used on either requests or responses) should probably be a server concern. It’s not actually really an encoding, rather a message framing.

Other transfer encodings, such as gzip, compress, and brotli ought to be an application-level concern. All of those can can be applied in addition to chunking, but can only ever be set on the response, since there’s no HTTP mechanism for negotiating supported encodings for the request body.

from asgiref.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

OK, let me revise the PR then.

from asgiref.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

PR (#96) updated - I have asserted that Transfer-Encoding is always the server's job, while applications can apply gzip, deflate, etc as Content-Encoding should they wish.

from asgiref.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

Last call - I'm going to merge the new PR that has Transfer-Encoding as the server's job both ways if nobody objects!

from asgiref.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

Finally merged.

from asgiref.

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.