Show
Ignore:
Timestamp:
04/22/08 17:10:38 (7 months ago)
Author:
mattn
Message:

lang/python/webSimple/webSimple.py:

  • ヘッダに対応(Basic認証等に使用)
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/python/webSimple/webSimple.py

    r9196 r10135  
    4545    query_path = url_param[2] 
    4646    query_params = url_param[4] 
     47    headers = {} 
    4748 
    4849    if isinstance(opt, dict): 
    4950      if opt.has_key('path'): 
    5051        query_path += opt['path'] 
     52      if opt.has_key('headers'): 
     53        headers.update(opt['headers']) 
    5154 
    5255    if isinstance(self.opt, dict): 
     
    5558          query_params += "&" 
    5659        query_params += "%s" % urllib.urlencode(self.opt['param']) 
     60      if self.opt.has_key('headers'): 
     61        headers.update(self.opt['headers']) 
    5762 
    5863    if isinstance(param, dict): 
     
    6368 
    6469    if use_google_api: 
    65       return Response(urlfetch.fetch(url).content) 
     70      return Response(urlfetch.fetch(url, headers=headers).content) 
    6671 
    67     return Response(urllib2.urlopen(urllib2.Request(url)).read()) 
     72    return Response(urllib2.urlopen(urllib2.Request(url, headers=headers)).read())