copy middleware support logic from 'master'
copy middleware support logic from 'master'

all work by @pkoretic

Signed-off-by: Mario Kozjak <33ca8347785e11ec875b554f3d6b1d87b5459732@gmail.com>

xwalk/recurse,qaap/recurse