<commit_before>module Siffer
  module Protocol
    
    class UnknownPath < Exception; end
    class NonPostRequest < Exception; end
    
    def request_failed_protocol?
      begin
        check_path_against_protocol
      rescue UnknownPath
        @response = Response.new(HTTP_STATUS_CODES[404],
                      404,
                      {"Content-Type" => Siffer::Messaging::MIME_TYPES["htm"]})
      rescue NonPostRequest
        @response = Response.new(HTTP_STATUS_CODES[405],
                      405,
                      {"Content-Type" => Siffer::Messaging::MIME_TYPES["htm"]})
      end
    end
    
    # Validates the request object against 
    # the Acceptable Paths (Siffer spec) and that
    # the request is a POST.
    def check_path_against_protocol
      unless ACCEPTABLE_PATHS.values.include? @request.path_info
        raise UnknownPath
      end
      unless @request.post? 
        raise NonPostRequest
      end
    end
    
    # Returns the URI of the component
    def uri
       URI.parse("http://#{host}:#{port}").to_s
    end
    <commit_msg>Added comments<commit_after>module Siffer
  module Protocol
    
    class UnknownPath < Exception; end
    class NonPostRequest < Exception; end
    
    def request_failed_protocol?
      begin
        check_path_against_protocol
      rescue UnknownPath
        # Do I want this to be a better 404 html response?
        @response = Response.new(HTTP_STATUS_CODES[404],
                      404,
                      {"Content-Type" => Siffer::Messaging::MIME_TYPES["htm"]})
      rescue NonPostRequest
        @response = Response.new(HTTP_STATUS_CODES[405],
                      405,
                      {"Content-Type" => Siffer::Messaging::MIME_TYPES["htm"]})
      end
    end
    
    # Validates the request object against 
    # the Acceptable Paths (Siffer spec) and that
    # the request is a POST.
    def check_path_against_protocol
      unless ACCEPTABLE_PATHS.values.include? @request.path_info
        raise UnknownPath
      end
      unless @request.post? 
        raise NonPostRequest
      end
    end
    
    # Returns the URI of the component
    def uri
       URI.parse("http://#{host}:#{port}").to_s
    end
    
{'fraction_non_alphanumeric': 0.07878245299910475, 'fraction_numerical': 0.012085944494180842, 'mean_word_length': 2.05327868852459, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6367947', 'n_tokens_mistral': 662, 'n_tokens_neox': 628, 'n_words': 158}