def client_requests_text_rewrite(raw_text):
 def replace_to_real_domain(match_obj):
  scheme = get_group('scheme', match_obj)
  colon = match_obj.group('colon')
  scheme_slash = get_group('scheme_slash', match_obj)
  _is_https = bool(get_group('is_https', match_obj))
  real_domain = match_obj.group('real_domain')
  result = ''
  if scheme:
   if ('http' in scheme):
    if (_is_https or is_target_domain_use_https(real_domain)):
     result += ('https' + colon)
    else:
     result += ('http' + colon)
   result += (scheme_slash * 2)
  result += real_domain
  return result
 replaced = regex_request_rewriter_extdomains.sub(replace_to_real_domain, raw_text)
 if ((developer_string_trace is not None) and (developer_string_trace in replaced)):
  infoprint('StringTrace: appears client_requests_text_rewrite, code line no. ', current_line_number())
 replaced = regex_request_rewriter_main_domain.sub(target_domain, replaced)
 replaced = replaced.replace(my_host_name, target_domain)
 dbgprint('ClientRequestedUrl: ', raw_text, '<- Has Been Rewrited To ->', replaced)
 return replaced

def client_requests_text_rewrite ( raw_text ) : def replace_to_real_domain ( match_obj ) : scheme = get_group ( 'scheme' , match_obj ) colon = match_obj . group ( 'colon' ) scheme_slash = get_group ( 'scheme_slash' , match_obj ) _is_https = bool ( get_group ( 'is_https' , match_obj ) ) real_domain = match_obj . group ( 'real_domain' ) result = '' if scheme : if ( 'http' in scheme ) : if ( _is_https or is_target_domain_use_https ( real_domain ) ) : result += ( 'https' + colon ) else : result += ( 'http' + colon ) result += ( scheme_slash * 2 ) result += real_domain return result replaced = regex_request_rewriter_extdomains . sub ( replace_to_real_domain , raw_text ) if ( ( developer_string_trace is not None ) and ( developer_string_trace in replaced ) ) : infoprint ( 'StringTrace: appears client_requests_text_rewrite, code line no. ' , current_line_number ( ) ) replaced = regex_request_rewriter_main_domain . sub ( target_domain , replaced ) replaced = replaced . replace ( my_host_name , target_domain ) dbgprint ( 'ClientRequestedUrl: ' , raw_text , '<- Has Been Rewrited To ->' , replaced ) return replaced
rewrite proxy domain to origin domain .