def upgrade_response(response):
 wrapper_class = get_seek_wrapper_class(response)
 if hasattr(response, 'closeable_response'):
  if (not hasattr(response, 'seek')):
   response = wrapper_class(response)
  assert hasattr(response, 'get_data')
  return copy.copy(response)
 try:
  code = response.code
 except AttributeError:
  code = None
 try:
  msg = response.msg
 except AttributeError:
  msg = None
 data = None
 get_data = getattr(response, 'get_data', None)
 if get_data:
  data = get_data()
 response = closeable_response(response.fp, response.info(), response.geturl(), code, msg)
 response = wrapper_class(response)
 if data:
  response.set_data(data)
 return response

def upgrade_response ( response ) : wrapper_class = get_seek_wrapper_class ( response ) if hasattr ( response , 'closeable_response' ) : if ( not hasattr ( response , 'seek' ) ) : response = wrapper_class ( response ) assert hasattr ( response , 'get_data' ) return copy . copy ( response ) try : code = response . code except AttributeError : code = None try : msg = response . msg except AttributeError : msg = None data = None get_data = getattr ( response , 'get_data' , None ) if get_data : data = get_data ( ) response = closeable_response ( response . fp , response . info ( ) , response . geturl ( ) , code , msg ) response = wrapper_class ( response ) if data : response . set_data ( data ) return response
return a copy of response that supports browser response interface .