Changeset 5095 for ndgCommon/trunk


Ignore:
Timestamp:
11/03/09 17:36:15 (11 years ago)
Author:
cbyrom
Message:

Extend http client to allow a payload to specified when reading a URL

  • via a new keyword.
File:
1 edited

Legend:

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

    r4997 r5095  
    3030 
    3131         
    32     def readURL(self, url): 
     32    def readURL(self, url, payload = 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 
     36        @keyword payload: data to POST in the request  
    3637        @raise IOError if problem experienced whilst opening url 
    3738        @return contents of url  
     
    3940        logging.info("Getting data from url: %s" %url) 
    4041        url = httpify(url) 
    41         request=urllib2.Request(url) 
     42        request=urllib2.Request(url, data = payload) 
    4243        response='Cannot obtain remote file: ' 
    4344        try: 
     45            # NB, if the connection is invalid, it will fail at this point 
    4446            f = self.opener.open(request) 
    4547            return f.read() 
Note: See TracChangeset for help on using the changeset viewer.