anchor.diff:  -module(chttpd).
   -include("chttpd.hrl").
   
  --export([start_link/0, stop/0, handle_request/5, config_change/2]).
  +-export([start_link/0, stop/0, handle_request/1, config_change/2]).
   
   -export([header_value/2,header_value/3,qs_value/2,qs_value/3,qs/1,path/1,absolute_uri/2,body_length/1]).
   -export([verify_is_server_admin/1,unquote/1,quote/1,recv/2,recv_chunked/4,error_info/1]).
  
positive.code: stop() ->
      mochiweb_http:stop(?MODULE).
  
  handle_request(MochiReq, DefaultFun,
          UrlHandlers, DbUrlHandlers, DesignUrlHandlers) ->
      Begin = now(),
  
      AuthenticationFuns = [
          fun chttpd_auth:cookie_authentication_handler/1,
  
negative.code: increment_method_stats(Method) ->
      couch_stats_collector:increment({httpd_request_methods, Method}).
  
  url_handlers() ->
      [
          {<<"/">>,               fun chttpd_misc:handle_welcome_req/1},
          {<<"favicon.ico">>,     fun chttpd_misc:handle_favicon_req/1},
          {<<"_utils">>,          fun chttpd_misc:handle_utils_dir_req/1},
          {<<"_all_dbs">>,        fun chttpd_misc:handle_all_dbs_req/1},
          {<<"_active_tasks">>,   fun chttpd_misc:handle_task_status_req/1},
          {<<"_config">>,         fun chttpd_misc:handle_config_req/1},
          {<<"_replicate">>,      fun chttpd_misc:handle_replicate_req/1},
          {<<"_uuids">>,          fun chttpd_misc:handle_uuids_req/1},
          {<<"_log">>,            fun chttpd_misc:handle_log_req/1},
          {<<"_sleep">>,          fun chttpd_misc:handle_sleep_req/1},
          {<<"_session">>,        fun chttpd_auth:handle_session_req/1},
          {<<"_user">>,           fun chttpd_auth:handle_user_req/1},
          {<<"_oauth">>,          fun chttpd_oauth:handle_oauth_req/1},
          {<<"_stats">>,          fun chttpd_stats:handle_stats_req/1},
          {<<"_restart">>,        fun showroom_http:handle_restart_req/1},
          {<<"_cloudant">>,       fun showroom_httpd_admin:handle_cloudant_req/1}
      ].
  
  db_url_handlers() ->
      [
          {<<"_view_cleanup">>,   fun chttpd_view:handle_view_cleanup_req/2},
          {<<"_compact">>,        fun chttpd_db:handle_compact_req/2},
          {<<"_design">>,         fun chttpd_db:handle_design_req/2},
          {<<"_view">>,           fun chttpd_db:handle_db_view_req/2},
          {<<"_temp_view">>,      fun chttpd_db:handle_temp_view_req/2},
          {<<"_changes">>,        fun chttpd_db:handle_changes_req/2}
      ].
  
  design_url_handlers() ->
      [
          {<<"_view">>,           fun chttpd_view:handle_view_req/2},
          {<<"_show">>,           fun chttpd_show:handle_doc_show_req/2},
          {<<"_list">>,           fun chttpd_show:handle_view_list_req/2},
          {<<"_update">>,         fun chttpd_show:handle_doc_update_req/2},
          {<<"_info">>,           fun chttpd_db:handle_design_info_req/2}
      ].
  
  % Utilities
  
  