GitHub user bgaff opened a pull request:

    https://github.com/apache/trafficserver/pull/351

    TS-4042: Add feature to buffer request body before making downstream 
requests

    We need a way to examine the request body without making a downstream 
request, this feature has many use cases including:
    
      - Ability to buffer the body and ensure a full post is received before 
committing downstream resources.
      - Ability to choose an origin based on request body
      - Ability to do request content filtering such as a WAF might provide 
before the origin is involved.
    
    Today you have two options to inspect a request body:
    
      1) Transformations: the problem with transformations is that you only 
start receiving the request bytes after a sink has been established, which in 
this case is the downstream origin.
      2) Create an intercept and use fetch apis to then send the downstream 
request: while this technically works it turns out to be a ton of code and is 
in general pretty problematic, we actually tried this approach for a while and 
had nothing but problems with it.
    
    We feel it would be ideal if we could intercept the body without breaking 
the normal ATS state flow. There used to exist code (and it's still in the core 
just #ifdefed out) to drain the request body. I use that code as the basis for 
this request buffering code. We added APIs to both the C and C++ APIs so that 
this request buffering can be enabled from a plugin and the plugin can inspect 
the body as chunks arrive or when it's complete. We've included an example 
plugin that will error a transaction if a minimum rate of transfer is not 
maintained. We've been using a very similar method in the core for buffer 
request bodies for several months without issues so the code that is new (for 
us) is basically all the API stuff.
    
    I'm confident that this feature will bring plenty of questions / feedback, 
so let's get that party started. @zwoop @SolidWallOfCode @jpeach @sudheerv : if 
you have time would you mind commenting / reviewing.
    
    cc. @jacksontj @zizhong @canselcik 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/bgaff/trafficserver TS-4042

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/trafficserver/pull/351.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #351
    
----
commit 6d0acd528cd09d17c92e5097710c1f192ef1f584
Author: Brian Geffon <bri...@apache.org>
Date:   2015-11-20T17:37:12Z

    TS-4042: Add feature to buffer request body before making downstream 
requests

commit 2b806a80ab3e0447d5b882b8b00afbeb59d6c8e1
Author: Brian Geffon <bri...@apache.org>
Date:   2015-11-20T17:43:44Z

    TS-4042: Add feature to buffer request body before making downstream 
requests: example C plugin.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to