Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow headers to be passed to an HTTP Check #541

Closed
alq666 opened this issue Jun 13, 2013 · 1 comment
Closed

Allow headers to be passed to an HTTP Check #541

alq666 opened this issue Jun 13, 2013 · 1 comment

Comments

@alq666
Copy link
Member

alq666 commented Jun 13, 2013

As requested by one of our users, here's how it can work:

instances:
  - name: my first service
    url: http://example.com
    timeout: 1
    headers:
      - content-type: application/weird
        user-agent: my-very-own
...

Once that bit is parsed, simply assemble the headers and send them along:

   def _check(self, instance):                                                                                                                              
        addr, username, password, timeout, include_content, headers = self._load_conf(instance)                                                                       
        content = ''                                                                                                                                         
        start = time.time()                                                                                                                                  
        try:                                                                                                                                                 
            self.log.debug("Connecting to %s" % addr)                                                                                                        
            h = Http(timeout=timeout, disable_ssl_certificate_validation=True)                                                                               
            if username is not None and password is not None:                                                                                                
                h.add_credentials(username, password)                                                                                                        
            resp, content = h.request(addr, "GET", headers=headers)   
@elijahandrews
Copy link
Contributor

Thanks Tom!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants