如何通过http在芹菜任务调用上设置http_头

如何通过http在芹菜任务调用上设置http_头,http,celery,django-celery,celery-task,djcelery,Http,Celery,Django Celery,Celery Task,Djcelery,我想使用HttpDispatch from Cellery类通过HTTP进行任务调用,但我需要设置授权头。我该怎么做 from celery.task.http import HttpDispatch request = HttpDispatch( url='http://example.com/multiply', method='GET', {10}) request.dispatch() 您将需要子类化HttpDispatch并重新实现http\u头property方

我想使用HttpDispatch from Cellery类通过HTTP进行任务调用,但我需要设置授权头。我该怎么做

from celery.task.http import HttpDispatch
request = HttpDispatch(
     url='http://example.com/multiply',
     method='GET', {10})
request.dispatch()

您将需要子类化
HttpDispatch
并重新实现
http\u头
property方法。此属性在
HttpDispatch
中使用

class CustomHttpDispatch(HttpDispatch):

@property
def http_headers(self):
    headers = {
        'User-Agent': self.user_agent,
        'Authorization': 'XXX'}

    return headers