fix content length stuff for middleware