Changeset 5443 for ndgCommon


Ignore:
Timestamp:
01/07/09 15:01:11 (10 years ago)
Author:
cbyrom
Message:

Add keyword to allow headers info to be set in generichttpclient.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/clients/http/generichttpclient.py

    r5095 r5443  
    3030 
    3131         
    32     def readURL(self, url, payload = None): 
     32    def readURL(self, url, payload = None, headersDict = None): 
    3333        ''' 
    3434        Retrieve contents of url - or raise IOError if a problem is found 
    3535        @param url: url to open and retrive data from 
    3636        @keyword payload: data to POST in the request  
     37        @keyword headersDict: dict with headers info to use in the request  
    3738        @raise IOError if problem experienced whilst opening url 
    3839        @return contents of url  
     
    4041        logging.info("Getting data from url: %s" %url) 
    4142        url = httpify(url) 
    42         request=urllib2.Request(url, data = payload) 
     43        inputs = {} 
     44        if payload: 
     45            inputs['data'] = payload 
     46             
     47        if headersDict: 
     48            inputs['headers'] = headersDict 
     49             
     50        request=urllib2.Request(url, **inputs) 
    4351        response='Cannot obtain remote file: ' 
    4452        try: 
Note: See TracChangeset for help on using the changeset viewer.