XHR transport refactoring and buffer alloc optimization