'Includes all the information about current Flask request context
as an additional argument to the task.'

def _include_request_context(self, kwargs):

    if (not has_request_context()):
        return
    context = {'path': request.path, 'base_url': request.url_root, 'method': request.method, 'headers': dict(request.headers)}
    if ('?' in request.url):
        context['query_string'] = request.url[(request.url.find('?') + 1):]
    kwargs[self.CONTEXT_ARG_NAME] = context
