<commit_before>##   RSence
 #   Copyright 2007 Riassence Inc.
 #   http://riassence.com/
 #
 #   You should have received a copy of the GNU General Public License along
 #   with this software package. If not, contact <EMAIL>
 ##


module ClientPkgServe
  def broker_urls
    ::RSence.config[:broker_urls]
  end
  
  def match( uri, request_type )
    uri.match( /^#{broker_urls[:h]}/ )
  end
  
  # Helper method to return the time formatted according to the HTTP RFC
  def httime(time)
    return time.gmtime.strftime('%a, %d %b %Y %H:%M:%S %Z')
  end
  
  def build_busy_wait
    while @build_busy
      puts "-- build not finished, waiting.. --"
      sleep 0.1
    end
  end
  
  def set_headers( response )
    # Sets the response date header to the current time:
    response['Date'] = httime( Time.now )
    
    # Controls caching with headers based on the configuration
    if ::RSence.config[:cache_maximize]
      response['Expires'] = httime(Time.now+::RSence.config[:cache_expire])
    else
      response['Cache-Control'] = 'no-cache'
    end
  end
  
  def check_ua( request )
    support_gzip = (request.header.has_key?('Accept-Encoding') and request.header['Accept-Encoding'].include?('gzip'))
    support_gzip = false if ::RSence.config[:no_gzip]
    if request.header.has_key?('User-Agent')
      ua = request.header['User-Agent']
      is_symbian = ua.include?("SymbianOS")
      is_safari  = ((not is_symbian) and ua.include?("WebKit"))
      is_msie = ((not ua.include?("Opera")) and ua.include?("MSIE"))
      is_msie6 = ((not ua.include?("Opera")) and ua.include?("MSIE 6.0"))
    end
    if is_safari
      version = ua.split( 'WebKit/' )[1].split('.')[0].to_i
    else
      version = 0 # not used for others<commit_msg>build busy sleeps for 400ms, but this needs to be resolved in a smarter way<commit_after>##   RSence
 #   Copyright 2007 Riassence Inc.
 #   http://riassence.com/
 #
 #   You should have received a copy of the GNU General Public License along
 #   with this software package. If not, contact <EMAIL>
 ##


module ClientPkgServe
  def broker_urls
    ::RSence.config[:broker_urls]
  end
  
  def match( uri, request_type )
    uri.match( /^#{broker_urls[:h]}/ )
  end
  
  # Helper method to return the time formatted according to the HTTP RFC
  def httime(time)
    return time.gmtime.strftime('%a, %d %b %Y %H:%M:%S %Z')
  end
  
  def build_busy_wait
    while @build_busy
      puts "-- build not finished, waiting.. --"
      sleep 0.4
    end
  end
  
  def set_headers( response )
    # Sets the response date header to the current time:
    response['Date'] = httime( Time.now )
    
    # Controls caching with headers based on the configuration
    if ::RSence.config[:cache_maximize]
      response['Expires'] = httime(Time.now+::RSence.config[:cache_expire])
    else
      response['Cache-Control'] = 'no-cache'
    end
  end
  
  def check_ua( request )
    support_gzip = (request.header.has_key?('Accept-Encoding') and request.header['Accept-Encoding'].include?('gzip'))
    support_gzip = false if ::RSence.config[:no_gzip]
    if request.header.has_key?('User-Agent')
      ua = request.header['User-Agent']
      is_symbian = ua.include?("SymbianOS")
      is_safari  = ((not is_symbian) and ua.include?("WebKit"))
      is_msie = ((not ua.include?("Opera")) and ua.include?("MSIE"))
      is_msie6 = ((not ua.include?("Opera")) and ua.include?("MSIE 6.0"))
    end
    if is_safari
      version = ua.split( 'WebKit/' )[1].split('.')[0].to_i
    else
      version = 0 # not used for others
{'fraction_non_alphanumeric': 0.13357705286839144, 'fraction_numerical': 0.007592800899887514, 'mean_word_length': 3.0744558991981674, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6602324', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1227, 'n_words': 323}