def set_user_agent(http, user_agent):
 request_orig = http.request
 def new_request(uri, method='GET', body=None, headers=None, redirections=httplib2.DEFAULT_MAX_REDIRECTS, connection_type=None):
  'Modify the request headers to add the user-agent.'
  if (headers is None):
   headers = {}
  if ('user-agent' in headers):
   headers['user-agent'] = ((user_agent + ' ') + headers['user-agent'])
  else:
   headers['user-agent'] = user_agent
  (resp, content) = request_orig(uri, method, body, headers, redirections, connection_type)
  return (resp, content)
 http.request = new_request
 return http

def set_user_agent ( http , user_agent ) : request_orig = http . request def new_request ( uri , method = 'GET' , body = None , headers = None , redirections = httplib2 . DEFAULT_MAX_REDIRECTS , connection_type = None ) : if ( headers is None ) : headers = { } if ( 'user-agent' in headers ) : headers [ 'user-agent' ] = ( ( user_agent + ' ' ) + headers [ 'user-agent' ] ) else : headers [ 'user-agent' ] = user_agent ( resp , content ) = request_orig ( uri , method , body , headers , redirections , connection_type ) return ( resp , content ) http . request = new_request return http
set the user-agent on every request .