1

I want to make a task call via HTTP using the class HttpDispatch from celery, but i need to set Authorization header. How can i do this?

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

1 Answers1

3

You will need to subclass HttpDispatch and reimplement http_headers property method. This property is used inside HttpDispatch.

class CustomHttpDispatch(HttpDispatch):

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

    return headers
Luiz de Prá
  • 1,475
  • 2
  • 12
  • 23