• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

HttpConfig.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 /*************************** -*- Mod: C++ -*- ******************************
00025 
00026   HttpConfig.h
00027    Created On      : Tue Oct 22 20:19:04 1996
00028 
00029    Description:
00030    Http Configurations
00031 
00032 
00033  ****************************************************************************/
00034 #ifndef _HttpConfig_h_
00035 #define _HttpConfig_h_
00036 
00037 #include <stdlib.h>
00038 #include <stdio.h>
00039 
00040 #ifdef HAVE_PCRE_PCRE_H
00041 #include <pcre/pcre.h>
00042 #else
00043 #include <pcre.h>
00044 #endif
00045 
00046 #ifdef HAVE_CTYPE_H
00047 #include <ctype.h>
00048 #endif
00049 
00050 #include "libts.h"
00051 #include "HttpProxyAPIEnums.h"
00052 #include "ProxyConfig.h"
00053 
00054 #include "P_RecProcess.h"
00055 
00056 /* Instead of enumerating the stats in DynamicStats.h, each module needs
00057    to enumerate its stats separately and register them with librecords
00058    */
00059 enum
00060 {
00061   http_background_fill_current_count_stat,
00062   http_current_client_connections_stat,
00063   http_current_active_client_connections_stat,
00064   http_websocket_current_active_client_connections_stat,
00065   http_current_client_transactions_stat,
00066   http_total_incoming_connections_stat,
00067   http_current_parent_proxy_transactions_stat,
00068   http_current_icp_transactions_stat,
00069   http_current_server_transactions_stat,
00070   http_current_parent_proxy_raw_transactions_stat,
00071   http_current_icp_raw_transactions_stat,
00072   http_current_server_raw_transactions_stat,
00073 
00074   //  Http Abort information (from HttpNetConnection)
00075   http_ua_msecs_counts_errors_pre_accept_hangups_stat,
00076   http_ua_msecs_counts_errors_empty_hangups_stat,
00077   http_ua_msecs_counts_errors_early_hangups_stat,
00078 
00079   // Http Total Connections Stats
00080   //
00081   // it is assumed that this inequality will always be satisifed:
00082   //   http_total_client_connections_stat >=
00083   //     http_total_client_connections_ipv4_stat +
00084   //     http_total_client_connections_ipv6_stat
00085   http_total_client_connections_stat,
00086   http_total_client_connections_ipv4_stat,
00087   http_total_client_connections_ipv6_stat,
00088   http_total_server_connections_stat,
00089   http_total_parent_proxy_connections_stat,
00090   http_current_parent_proxy_connections_stat,
00091   http_current_server_connections_stat,
00092   http_current_cache_connections_stat,
00093 
00094   // Http K-A Stats
00095   http_transactions_per_client_con,
00096   http_transactions_per_server_con,
00097   http_transactions_per_parent_con,
00098 
00099   // Http Time Stuff
00100   http_client_connection_time_stat,
00101   http_parent_proxy_connection_time_stat,
00102   http_server_connection_time_stat,
00103   http_cache_connection_time_stat,
00104 
00105 
00106   // Transactional stats (originaly in proxy/HttpTransStats.h)
00107   http_incoming_requests_stat,
00108   http_outgoing_requests_stat,
00109   http_incoming_responses_stat,
00110   http_invalid_client_requests_stat,
00111   http_missing_host_hdr_stat,
00112   http_get_requests_stat,
00113   http_head_requests_stat,
00114   http_trace_requests_stat,
00115   http_options_requests_stat,
00116   http_post_requests_stat,
00117   http_put_requests_stat,
00118   http_push_requests_stat,
00119   http_delete_requests_stat,
00120   http_purge_requests_stat,
00121   http_connect_requests_stat,
00122   http_extension_method_requests_stat,
00123 
00124   http_completed_requests_stat,
00125 
00126   http_client_no_cache_requests_stat,
00127 
00128   //    http_icp_requests_stat,
00129   //    http_icp_invalid_responses_stat,
00130   //    http_parent_proxy_requests_stat,
00131   //    http_parent_invalid_responses_stat,
00132   //    http_invalid_responses_stat,
00133   //    http_retried_requests_stat,
00134 
00135   http_broken_server_connections_stat,
00136 
00137   http_cache_lookups_stat,
00138   http_cache_misses_stat,
00139   http_cache_writes_stat,
00140   http_cache_updates_stat,
00141   http_cache_deletes_stat,
00142 
00143   http_tunnels_stat,
00144   http_throttled_proxy_only_stat,
00145 
00146   http_icp_suggested_lookups_stat,
00147 
00148   // document size stats
00149   http_user_agent_request_header_total_size_stat,
00150   http_user_agent_response_header_total_size_stat,
00151   http_user_agent_request_document_total_size_stat,
00152   http_user_agent_response_document_total_size_stat,
00153 
00154   http_origin_server_request_header_total_size_stat,
00155   http_origin_server_response_header_total_size_stat,
00156   http_origin_server_request_document_total_size_stat,
00157   http_origin_server_response_document_total_size_stat,
00158 
00159   http_parent_proxy_request_total_bytes_stat,
00160   http_parent_proxy_response_total_bytes_stat,
00161 
00162   http_pushed_response_header_total_size_stat,
00163   http_pushed_document_total_size_stat,
00164 
00165   http_background_fill_bytes_aborted_stat,
00166   http_background_fill_bytes_completed_stat,
00167 
00168   http_response_document_size_100_stat,
00169   http_response_document_size_1K_stat,
00170   http_response_document_size_3K_stat,
00171   http_response_document_size_5K_stat,
00172   http_response_document_size_10K_stat,
00173   http_response_document_size_1M_stat,
00174   http_response_document_size_inf_stat,
00175 
00176   http_request_document_size_100_stat,
00177   http_request_document_size_1K_stat,
00178   http_request_document_size_3K_stat,
00179   http_request_document_size_5K_stat,
00180   http_request_document_size_10K_stat,
00181   http_request_document_size_1M_stat,
00182   http_request_document_size_inf_stat,
00183 
00184   // connection speed stats
00185   http_user_agent_speed_bytes_per_sec_100_stat,
00186   http_user_agent_speed_bytes_per_sec_1K_stat,
00187   http_user_agent_speed_bytes_per_sec_10K_stat,
00188   http_user_agent_speed_bytes_per_sec_100K_stat,
00189   http_user_agent_speed_bytes_per_sec_1M_stat,
00190   http_user_agent_speed_bytes_per_sec_10M_stat,
00191   http_user_agent_speed_bytes_per_sec_100M_stat,
00192   http_origin_server_speed_bytes_per_sec_100_stat,
00193   http_origin_server_speed_bytes_per_sec_1K_stat,
00194   http_origin_server_speed_bytes_per_sec_10K_stat,
00195   http_origin_server_speed_bytes_per_sec_100K_stat,
00196   http_origin_server_speed_bytes_per_sec_1M_stat,
00197   http_origin_server_speed_bytes_per_sec_10M_stat,
00198   http_origin_server_speed_bytes_per_sec_100M_stat,
00199 
00200   // cache result stats
00201   http_cache_hit_fresh_stat,
00202   http_cache_hit_mem_fresh_stat,
00203   http_cache_hit_reval_stat,
00204   http_cache_hit_ims_stat,
00205   http_cache_hit_stale_served_stat,
00206   http_cache_miss_cold_stat,
00207   http_cache_miss_changed_stat,
00208   http_cache_miss_client_no_cache_stat,
00209   http_cache_miss_uncacheable_stat,
00210   http_cache_miss_ims_stat,
00211   http_cache_read_error_stat,
00212 
00213   // bandwidth savings stats
00214   http_tcp_hit_count_stat,
00215   http_tcp_hit_user_agent_bytes_stat,
00216   http_tcp_hit_origin_server_bytes_stat,
00217   http_tcp_miss_count_stat,
00218   http_tcp_miss_user_agent_bytes_stat,
00219   http_tcp_miss_origin_server_bytes_stat,
00220   http_tcp_expired_miss_count_stat,
00221   http_tcp_expired_miss_user_agent_bytes_stat,
00222   http_tcp_expired_miss_origin_server_bytes_stat,
00223   http_tcp_refresh_hit_count_stat,
00224   http_tcp_refresh_hit_user_agent_bytes_stat,
00225   http_tcp_refresh_hit_origin_server_bytes_stat,
00226   http_tcp_refresh_miss_count_stat,
00227   http_tcp_refresh_miss_user_agent_bytes_stat,
00228   http_tcp_refresh_miss_origin_server_bytes_stat,
00229   http_tcp_client_refresh_count_stat,
00230   http_tcp_client_refresh_user_agent_bytes_stat,
00231   http_tcp_client_refresh_origin_server_bytes_stat,
00232   http_tcp_ims_hit_count_stat,
00233   http_tcp_ims_hit_user_agent_bytes_stat,
00234   http_tcp_ims_hit_origin_server_bytes_stat,
00235   http_tcp_ims_miss_count_stat,
00236   http_tcp_ims_miss_user_agent_bytes_stat,
00237   http_tcp_ims_miss_origin_server_bytes_stat,
00238   http_err_client_abort_count_stat,
00239   http_err_client_abort_user_agent_bytes_stat,
00240   http_err_client_abort_origin_server_bytes_stat,
00241   http_err_connect_fail_count_stat,
00242   http_err_connect_fail_user_agent_bytes_stat,
00243   http_err_connect_fail_origin_server_bytes_stat,
00244   http_misc_count_stat,
00245   http_misc_user_agent_bytes_stat,
00246   http_misc_origin_server_bytes_stat,
00247 
00248   // http - time and count of transactions classified by client's point of view
00249   http_ua_msecs_counts_hit_fresh_stat,
00250 
00251   http_ua_msecs_counts_hit_fresh_process_stat,
00252   http_ua_msecs_counts_hit_reval_stat,
00253   http_ua_msecs_counts_hit_ims_stat,
00254   http_ua_msecs_counts_hit_stale_served_stat,
00255   http_ua_msecs_counts_miss_cold_stat,
00256   http_ua_msecs_counts_miss_changed_stat,
00257   http_ua_msecs_counts_miss_client_no_cache_stat,
00258   http_ua_msecs_counts_miss_uncacheable_stat,
00259   http_ua_msecs_counts_miss_ims_stat,
00260   http_ua_msecs_counts_errors_aborts_stat,
00261   http_ua_msecs_counts_errors_possible_aborts_stat,
00262   http_ua_msecs_counts_errors_connect_failed_stat,
00263   http_ua_msecs_counts_errors_other_stat,
00264   http_ua_msecs_counts_other_unclassified_stat,
00265 
00266   http_total_x_redirect_stat,
00267 
00268   // Times
00269   http_total_transactions_time_stat,
00270   http_total_transactions_think_time_stat,
00271 
00272   http_client_transaction_time_stat,
00273 
00274   http_client_write_time_stat,
00275   http_server_read_time_stat,
00276 
00277   http_icp_transaction_time_stat,
00278   http_icp_raw_transaction_time_stat,
00279   http_parent_proxy_transaction_time_stat,
00280   http_parent_proxy_raw_transaction_time_stat,
00281   http_server_transaction_time_stat,
00282   http_server_raw_transaction_time_stat,
00283 
00284   // Http cache errors
00285   http_cache_write_errors,
00286   http_cache_read_errors,
00287 
00288   // status code stats
00289   http_response_status_100_count_stat,
00290   http_response_status_101_count_stat,
00291   http_response_status_1xx_count_stat,
00292   http_response_status_200_count_stat,
00293   http_response_status_201_count_stat,
00294   http_response_status_202_count_stat,
00295   http_response_status_203_count_stat,
00296   http_response_status_204_count_stat,
00297   http_response_status_205_count_stat,
00298   http_response_status_206_count_stat,
00299   http_response_status_2xx_count_stat,
00300   http_response_status_300_count_stat,
00301   http_response_status_301_count_stat,
00302   http_response_status_302_count_stat,
00303   http_response_status_303_count_stat,
00304   http_response_status_304_count_stat,
00305   http_response_status_305_count_stat,
00306   http_response_status_307_count_stat,
00307   http_response_status_3xx_count_stat,
00308   http_response_status_400_count_stat,
00309   http_response_status_401_count_stat,
00310   http_response_status_402_count_stat,
00311   http_response_status_403_count_stat,
00312   http_response_status_404_count_stat,
00313   http_response_status_405_count_stat,
00314   http_response_status_406_count_stat,
00315   http_response_status_407_count_stat,
00316   http_response_status_408_count_stat,
00317   http_response_status_409_count_stat,
00318   http_response_status_410_count_stat,
00319   http_response_status_411_count_stat,
00320   http_response_status_412_count_stat,
00321   http_response_status_413_count_stat,
00322   http_response_status_414_count_stat,
00323   http_response_status_415_count_stat,
00324   http_response_status_416_count_stat,
00325   http_response_status_4xx_count_stat,
00326   http_response_status_500_count_stat,
00327   http_response_status_501_count_stat,
00328   http_response_status_502_count_stat,
00329   http_response_status_503_count_stat,
00330   http_response_status_504_count_stat,
00331   http_response_status_505_count_stat,
00332   http_response_status_5xx_count_stat,
00333 
00334   https_incoming_requests_stat,
00335   https_total_client_connections_stat,
00336 
00337   http_stat_count
00338 };
00339 
00340 extern RecRawStatBlock *http_rsb;
00341 
00342 /* Stats should only be accessed using these macros */
00343 #define HTTP_INCREMENT_DYN_STAT(x) RecIncrRawStat(http_rsb, mutex->thread_holding, (int) x, 1)
00344 #define HTTP_DECREMENT_DYN_STAT(x) RecIncrRawStat(http_rsb, mutex->thread_holding, (int) x, -1)
00345 #define HTTP_SUM_DYN_STAT(x, y) RecIncrRawStat(http_rsb, mutex->thread_holding, (int) x, (int64_t) y)
00346 #define HTTP_SUM_GLOBAL_DYN_STAT(x, y) RecIncrGlobalRawStatSum(http_rsb, x, y)
00347 
00348 #define HTTP_CLEAR_DYN_STAT(x) \
00349 do { \
00350         RecSetRawStatSum(http_rsb, x, 0); \
00351         RecSetRawStatCount(http_rsb, x, 0); \
00352  } while (0);
00353 
00354 #define HTTP_READ_DYN_SUM(x, S) RecGetRawStatSum(http_rsb, (int)x, &S) // This aggregates threads too
00355 #define HTTP_READ_GLOBAL_DYN_SUM(x, S) RecGetGlobalRawStatSum(http_rsb, (int)x, &S)
00356 
00357 #define HTTP_ConfigReadInteger         REC_ConfigReadInteger
00358 #define HTTP_ConfigReadString          REC_ConfigReadString
00359 #define HTTP_RegisterConfigUpdateFunc  REC_RegisterConfigUpdateFunc
00360 
00361 /////////////////////////////////////////////////////////////
00362 //
00363 // struct HttpConfigPortRange
00364 //
00365 // configuration parameters for a range of valid SSL ports
00366 // if "low" == "high" a single port is part of this range
00367 // if "low" == "high" == -1 any port number is allowed
00368 //   (corresponds to a "*" in the config file)
00369 /////////////////////////////////////////////////////////////
00370 struct HttpConfigPortRange
00371 {
00372   int low;
00373   int high;
00374   HttpConfigPortRange *next;
00375 
00376   HttpConfigPortRange()
00377     : low(0), high(0), next(0)
00378   {  }
00379 
00380   ~HttpConfigPortRange()
00381   {
00382     if (next)
00383       delete next;
00384   }
00385 };
00386 
00387 /////////////////////////////////////////////////////////////
00388 // This is a little helper class, used by the HttpConfigParams
00389 // and State (txn) structure. It allows for certain configs
00390 // to be overridable per transaction more easily.
00391 struct OverridableHttpConfigParams {
00392   OverridableHttpConfigParams()
00393     : maintain_pristine_host_hdr(1), chunking_enabled(1),
00394       negative_caching_enabled(0), negative_revalidating_enabled(0), cache_when_to_revalidate(0),
00395       keep_alive_enabled_in(1), keep_alive_enabled_out(1), keep_alive_post_out(1),
00396       server_session_sharing_match(TS_SERVER_SESSION_SHARING_MATCH_BOTH),
00397       server_session_sharing_pool(TS_SERVER_SESSION_SHARING_POOL_THREAD),
00398       auth_server_session_private(1), fwd_proxy_auth_to_parent(0), insert_age_in_response(1),
00399       anonymize_remove_from(0), anonymize_remove_referer(0), anonymize_remove_user_agent(0),
00400       anonymize_remove_cookie(0), anonymize_remove_client_ip(0), anonymize_insert_client_ip(1),
00401       proxy_response_server_enabled(1), proxy_response_hsts_max_age(-1), proxy_response_hsts_include_subdomains(0),
00402       insert_squid_x_forwarded_for(1), send_http11_requests(1),
00403       cache_http(1), cache_cluster_cache_local(0), cache_ignore_client_no_cache(1), cache_ignore_client_cc_max_age(0),
00404       cache_ims_on_client_no_cache(1), cache_ignore_server_no_cache(0), cache_responses_to_cookies(1),
00405       cache_ignore_auth(0), cache_urls_that_look_dynamic(1), cache_required_headers(2),
00406       cache_range_lookup(1), cache_range_write(0),
00407       insert_request_via_string(1), insert_response_via_string(0), doc_in_cache_skip_dns(1),
00408       flow_control_enabled(0), accept_encoding_filter_enabled(0), normalize_ae_gzip(0),
00409       negative_caching_lifetime(1800), negative_revalidating_lifetime(1800),
00410       sock_recv_buffer_size_out(0), sock_send_buffer_size_out(0), sock_option_flag_out(0),
00411       sock_packet_mark_out(0), sock_packet_tos_out(0), server_tcp_init_cwnd(0),
00412       request_hdr_max_size(131072), response_hdr_max_size(131072), post_check_content_length_enabled(1),
00413       cache_heuristic_min_lifetime(3600), cache_heuristic_max_lifetime(86400),
00414       cache_guaranteed_min_lifetime(0), cache_guaranteed_max_lifetime(31536000), cache_max_stale_age(604800),
00415       keep_alive_no_activity_timeout_in(115), keep_alive_no_activity_timeout_out(120),
00416       transaction_no_activity_timeout_in(30), transaction_no_activity_timeout_out(30),
00417       transaction_active_timeout_out(0), origin_max_connections(0),
00418       connect_attempts_max_retries(0), connect_attempts_max_retries_dead_server(3),
00419       connect_attempts_rr_retries(3), connect_attempts_timeout(30),
00420       post_connect_attempts_timeout(1800), down_server_timeout(300), client_abort_threshold(10),
00421       freshness_fuzz_time(240), freshness_fuzz_min_time(0),
00422       max_cache_open_read_retries(-1), cache_open_read_retry_time(10), background_fill_active_timeout(60),
00423       http_chunking_size(4096), flow_high_water_mark(0), flow_low_water_mark(0),
00424       default_buffer_size_index(8), default_buffer_water_mark(32768),
00425 
00426       // Strings / floats must come last
00427       proxy_response_server_string(NULL), proxy_response_server_string_len(0),
00428       global_user_agent_header(NULL), global_user_agent_header_size(0),
00429       cache_heuristic_lm_factor(0.10), freshness_fuzz_prob(0.005),
00430       background_fill_threshold(0.5)
00431   { }
00432 
00433   // A few rules here:
00434   //   1. Place all MgmtByte configs before all other configs
00435   //   1. all MgmtInt/Byte configs should come before string / float configs.
00436 
00437   // The first three configs used to be @-parameters in remap.config
00438   MgmtByte maintain_pristine_host_hdr;
00439   MgmtByte chunking_enabled;
00440 
00441   ////////////////////////////////
00442   //  Negative Response Caching //
00443   ////////////////////////////////
00444   MgmtByte negative_caching_enabled;
00445   MgmtByte negative_revalidating_enabled;
00446 
00447   MgmtByte cache_when_to_revalidate;
00448 
00449   MgmtByte keep_alive_enabled_in;
00450   MgmtByte keep_alive_enabled_out;
00451   MgmtByte keep_alive_post_out;  // share server sessions for post
00452 
00453   MgmtByte server_session_sharing_match;
00454   MgmtByte server_session_sharing_pool;
00455   //  MgmtByte share_server_sessions;
00456   MgmtByte auth_server_session_private;
00457   MgmtByte fwd_proxy_auth_to_parent;
00458 
00459   MgmtByte insert_age_in_response;
00460 
00461   ///////////////////////////////////////////////////////////////////
00462   // Privacy: fields which are removed from the user agent request //
00463   ///////////////////////////////////////////////////////////////////
00464   MgmtByte anonymize_remove_from;
00465   MgmtByte anonymize_remove_referer;
00466   MgmtByte anonymize_remove_user_agent;
00467   MgmtByte anonymize_remove_cookie;
00468   MgmtByte anonymize_remove_client_ip;
00469   MgmtByte anonymize_insert_client_ip;
00470 
00471   MgmtByte proxy_response_server_enabled;
00472   MgmtInt proxy_response_hsts_max_age;
00473   MgmtByte proxy_response_hsts_include_subdomains;
00474 
00475   /////////////////////
00476   // X-Forwarded-For //
00477   /////////////////////
00478   MgmtByte insert_squid_x_forwarded_for;
00479 
00480   //////////////////////
00481   //  Version Hell    //
00482   //////////////////////
00483   MgmtByte send_http11_requests;
00484 
00485   ///////////////////
00486   // cache control //
00487   ///////////////////
00488   MgmtByte cache_http;
00489   MgmtByte cache_cluster_cache_local;
00490   MgmtByte cache_ignore_client_no_cache;
00491   MgmtByte cache_ignore_client_cc_max_age;
00492   MgmtByte cache_ims_on_client_no_cache;
00493   MgmtByte cache_ignore_server_no_cache;
00494   MgmtByte cache_responses_to_cookies;
00495   MgmtByte cache_ignore_auth;
00496   MgmtByte cache_urls_that_look_dynamic;
00497   MgmtByte cache_required_headers;
00498   MgmtByte cache_range_lookup;
00499   MgmtByte cache_range_write;
00500 
00501   MgmtByte insert_request_via_string;
00502   MgmtByte insert_response_via_string;
00503 
00504   //////////////////////
00505   //  DOC IN CACHE NO DNS//
00506   //////////////////////
00507   MgmtByte doc_in_cache_skip_dns;
00508   MgmtByte flow_control_enabled;
00509 
00510   ////////////////////////////////////////////////////////
00511   // HTTP Accept-Encoding filtering based on User-Agent //
00512   ////////////////////////////////////////////////////////
00513   MgmtByte accept_encoding_filter_enabled;
00514 
00515   ////////////////////////////////
00516   // Optimize gzip alternates   //
00517   ////////////////////////////////
00518   MgmtByte normalize_ae_gzip;
00519 
00520   ////////////////////////////////
00521   //  Negative cache lifetimes  //
00522   ////////////////////////////////
00523   MgmtInt negative_caching_lifetime;
00524   MgmtInt negative_revalidating_lifetime;
00525 
00526   ///////////////////////////////////////
00527   // origin server connection settings //
00528   ///////////////////////////////////////
00529   MgmtInt sock_recv_buffer_size_out;
00530   MgmtInt sock_send_buffer_size_out;
00531   MgmtInt sock_option_flag_out;
00532   MgmtInt sock_packet_mark_out;
00533   MgmtInt sock_packet_tos_out;
00534 
00535   ///////////////////////////////
00536   // Initial congestion window //
00537   ///////////////////////////////
00538   MgmtInt server_tcp_init_cwnd;
00539 
00540   ///////////////
00541   // Hdr Limit //
00542   ///////////////
00543   MgmtInt request_hdr_max_size;
00544   MgmtInt response_hdr_max_size;
00545 
00546   ////////////////////////
00547   // Check Post request //
00548   ////////////////////////
00549   MgmtByte post_check_content_length_enabled;
00550 
00551   /////////////////////
00552   // cache variables //
00553   /////////////////////
00554   MgmtInt cache_heuristic_min_lifetime;
00555   MgmtInt cache_heuristic_max_lifetime;
00556   MgmtInt cache_guaranteed_min_lifetime;
00557   MgmtInt cache_guaranteed_max_lifetime;
00558   MgmtInt cache_max_stale_age;
00559 
00560   ///////////////////////////////////////////////////
00561   // connection variables. timeouts are in seconds //
00562   ///////////////////////////////////////////////////
00563   MgmtInt keep_alive_no_activity_timeout_in;
00564   MgmtInt keep_alive_no_activity_timeout_out;
00565   MgmtInt transaction_no_activity_timeout_in;
00566   MgmtInt transaction_no_activity_timeout_out;
00567   MgmtInt transaction_active_timeout_out;
00568   MgmtInt origin_max_connections;
00569 
00570   ////////////////////////////////////
00571   // origin server connect attempts //
00572   ////////////////////////////////////
00573   MgmtInt connect_attempts_max_retries;
00574   MgmtInt connect_attempts_max_retries_dead_server;
00575   MgmtInt connect_attempts_rr_retries;
00576   MgmtInt connect_attempts_timeout;
00577   MgmtInt post_connect_attempts_timeout;
00578 
00579   MgmtInt down_server_timeout;
00580   MgmtInt client_abort_threshold;
00581 
00582   MgmtInt freshness_fuzz_time;
00583   MgmtInt freshness_fuzz_min_time;
00584 
00585   // open read failure retries.
00586   MgmtInt max_cache_open_read_retries;
00587   MgmtInt cache_open_read_retry_time;   // time is in mseconds
00588 
00589   MgmtInt background_fill_active_timeout;
00590 
00591   MgmtInt http_chunking_size; // Maximum chunk size for chunked output.
00592   MgmtInt flow_high_water_mark; ///< Flow control high water mark.
00593   MgmtInt flow_low_water_mark; ///< Flow control low water mark.
00594 
00595   MgmtInt default_buffer_size_index;
00596   MgmtInt default_buffer_water_mark;
00597 
00598   // IMPORTANT: Here comes all strings / floats configs.
00599 
00600   ///////////////////////////////////////////////////////////////////
00601   // Server header                                                 //
00602   ///////////////////////////////////////////////////////////////////
00603   char *proxy_response_server_string; // This does not get free'd by us!
00604   size_t proxy_response_server_string_len; // Updated when server_string is set.
00605 
00606   ///////////////////////////////////////////////////////////////////
00607   // Global User Agent header                                                 //
00608   ///////////////////////////////////////////////////////////////////
00609   char *global_user_agent_header; // This does not get free'd by us!
00610   size_t global_user_agent_header_size; // Updated when user_agent is set.
00611 
00612   MgmtFloat cache_heuristic_lm_factor;
00613   MgmtFloat freshness_fuzz_prob;
00614   MgmtFloat background_fill_threshold;
00615 };
00616 
00617 
00618 /////////////////////////////////////////////////////////////
00619 //
00620 // struct HttpConfigParams
00621 //
00622 // configuration parameters as they apear in the global
00623 // configuration file.
00624 /////////////////////////////////////////////////////////////
00625 struct HttpConfigParams:public ConfigInfo
00626 {
00627 public:
00628   HttpConfigParams();
00629   ~HttpConfigParams();
00630 
00631   enum
00632   {
00633     CACHE_REQUIRED_HEADERS_NONE = 0,
00634     CACHE_REQUIRED_HEADERS_AT_LEAST_LAST_MODIFIED = 1,
00635     CACHE_REQUIRED_HEADERS_CACHE_CONTROL = 2
00636   };
00637 
00638   enum
00639   {
00640     SEND_HTTP11_NEVER = 0,
00641     SEND_HTTP11_ALWAYS = 1,
00642     SEND_HTTP11_UPGRADE_HOSTDB = 2,
00643     SEND_HTTP11_IF_REQUEST_11_AND_HOSTDB = 3
00644   };
00645 
00646 public:
00647   char *proxy_hostname;
00648   int proxy_hostname_len;
00649 
00650   IpAddr inbound_ip4, inbound_ip6;
00651   IpAddr outbound_ip4, outbound_ip6;
00652 
00653   MgmtInt server_max_connections;
00654   MgmtInt origin_min_keep_alive_connections; // TODO: This one really ought to be overridable, but difficult right now.
00655   MgmtInt attach_server_session_to_client;
00656 
00657   MgmtByte parent_proxy_routing_enable;
00658   MgmtByte disable_ssl_parenting;
00659 
00660   MgmtByte enable_url_expandomatic;
00661   MgmtByte no_dns_forward_to_parent;
00662   MgmtByte uncacheable_requests_bypass_parent;
00663   MgmtByte no_origin_server_dns;
00664   MgmtByte use_client_target_addr;
00665   MgmtByte use_client_source_port;
00666 
00667   char *proxy_request_via_string;
00668   int proxy_request_via_string_len;
00669   char *proxy_response_via_string;
00670   int proxy_response_via_string_len;
00671 
00672   ///////////////////////////////////
00673   // URL expansions for DNS lookup //
00674   ///////////////////////////////////
00675   char *url_expansions_string;
00676   char **url_expansions;
00677   int num_url_expansions;
00678 
00679   ///////////////////////////////////////////////////
00680   // connection variables. timeouts are in seconds //
00681   ///////////////////////////////////////////////////
00682   MgmtByte session_auth_cache_keep_alive_enabled;
00683   MgmtInt transaction_active_timeout_in;
00684   MgmtInt accept_no_activity_timeout;
00685 
00686   ////////////////////////////////////
00687   // origin server connect attempts //
00688   ////////////////////////////////////
00689   MgmtInt parent_connect_attempts;
00690   MgmtInt per_parent_connect_attempts;
00691   MgmtInt parent_connect_timeout;
00692 
00693   ///////////////////////////////////////////////////////////////////
00694   // Privacy: fields which are removed from the user agent request //
00695   ///////////////////////////////////////////////////////////////////
00696   char *anonymize_other_header_list;
00697 
00698   MgmtByte enable_http_stats; // Can be "slow"
00699 
00700   ///////////////////
00701   // ICP variables //
00702   ///////////////////
00703   MgmtByte icp_enabled;
00704   MgmtByte stale_icp_enabled;
00705 
00706   char *cache_vary_default_text;
00707   char *cache_vary_default_images;
00708   char *cache_vary_default_other;
00709 
00710   // open write failure retries.
00711   MgmtInt max_cache_open_write_retries;
00712 
00713   ///////////////////
00714   // cache control //
00715   ///////////////////
00716   MgmtByte cache_enable_default_vary_headers;
00717   MgmtByte cache_post_method;
00718 
00719   ////////////////////////////////////////////
00720   // CONNECT ports (used to be == ssl_ports //
00721   ////////////////////////////////////////////
00722   char *connect_ports_string;
00723   HttpConfigPortRange *connect_ports;
00724 
00725   //////////
00726   // Push //
00727   //////////
00728   MgmtByte push_method_enabled;
00729 
00730   ////////////////////////////
00731   // HTTP Referer filtering //
00732   ////////////////////////////
00733   MgmtByte referer_filter_enabled;
00734   MgmtByte referer_format_redirect;
00735 
00736   ///////////////////
00737   // reverse proxy //
00738   ///////////////////
00739   MgmtByte reverse_proxy_enabled;
00740   MgmtByte url_remap_required;
00741   char *reverse_proxy_no_host_redirect;
00742   int reverse_proxy_no_host_redirect_len;
00743 
00744   ///////////////////
00745   // cop access    //
00746   ///////////////////
00747   MgmtByte record_cop_page;
00748 
00749   /////////////////////
00750   // Error Reporting //
00751   /////////////////////
00752   MgmtByte errors_log_error_pages;
00753   MgmtInt slow_log_threshold;
00754 
00755   MgmtByte enable_http_info;
00756 
00757   // Cluster time delta is not a config variable,
00758   //  rather it is the time skew which the manager observes
00759   int32_t cluster_time_delta;
00760 
00761   //##############################################################################
00762   //#
00763   //# Redirection
00764   //#
00765   //# 1. redirection_enabled: if set to 1, redirection is enabled.
00766   //# 2. number_of_redirectionse: The maximum number of redirections YTS permits
00767   //# 3. post_copy_size: The maximum POST data size YTS permits to copy
00768   //#
00769   //##############################################################################
00770 
00771   MgmtByte redirection_enabled;
00772   MgmtByte redirection_host_no_port;
00773   MgmtInt number_of_redirections;
00774   MgmtInt post_copy_size;
00775 
00776   //////////////////////////////////////////////////////////////////
00777   // Allow special handling of Accept* headers to be disabled to  //
00778   // avoid unnecessary creation of alternates                     //
00779   //////////////////////////////////////////////////////////////////
00780   MgmtByte ignore_accept_mismatch;
00781   MgmtByte ignore_accept_language_mismatch;
00782   MgmtByte ignore_accept_encoding_mismatch;
00783   MgmtByte ignore_accept_charset_mismatch;
00784 
00785   MgmtByte send_100_continue_response;
00786 
00787   OverridableHttpConfigParams oride;
00788 
00789   ////////////////////
00790   // Local Manager  //
00791   ////////////////////
00792   MgmtInt autoconf_port;
00793   MgmtByte autoconf_localhost_only;
00794 
00795 
00796 private:
00797   /////////////////////////////////////
00798   // operator = and copy constructor //
00799   /////////////////////////////////////
00800     HttpConfigParams(const HttpConfigParams &);
00801     HttpConfigParams & operator =(const HttpConfigParams &);
00802 };
00803 
00804 /////////////////////////////////////////////////////////////
00805 //
00806 // class HttpUserAgent_RegxEntry
00807 //
00808 // configuration entry for specific User-Agent
00809 // Created at startup time only and never changed
00810 // The main purpose of the User-Agent filtering is to find "bad" user agents
00811 // and modify Accept-Encoding to prevent compression for such "bad" guys
00812 /////////////////////////////////////////////////////////////
00813 
00814 class HttpUserAgent_RegxEntry
00815 {
00816 public:
00817   typedef enum
00818   {                             // for more details, please see comments in "ae_ua.config" file
00819     STRTYPE_UNKNOWN = 0,
00820     STRTYPE_SUBSTR_CASE,        /* .substring, .string */
00821     STRTYPE_SUBSTR_NCASE,       /* .substring_ncase, .string_ncase */
00822     STRTYPE_REGEXP              /* .regexp POSIX regular expression */
00823   } StrType;
00824 
00825   HttpUserAgent_RegxEntry *next;
00826   int user_agent_str_size;
00827   char *user_agent_str;
00828   bool regx_valid;
00829   StrType stype;
00830   pcre* regx;
00831 
00832     HttpUserAgent_RegxEntry();
00833    ~HttpUserAgent_RegxEntry();
00834 
00835   bool create(char *refexp_str = NULL, char *errmsgbuf = NULL, int errmsgbuf_size = 0);
00836 };
00837 
00838 /////////////////////////////////////////////////////////////
00839 //
00840 // class HttpConfig
00841 //
00842 /////////////////////////////////////////////////////////////
00843 class HttpConfig
00844 {
00845 public:
00846 
00847   static int init_aeua_filter(char *config_fname);
00848 
00849   static void startup();
00850 
00851   static void reconfigure();
00852 
00853   inkcoreapi static HttpConfigParams *acquire();
00854   inkcoreapi static void release(HttpConfigParams * params);
00855 
00856   // dump
00857   static void dump_config();
00858 
00859   // parse ssl ports configuration string
00860   static HttpConfigPortRange *parse_ports_list(char *ports_str);
00861 
00862   // parse DNS URL expansions string
00863   static char **parse_url_expansions(char *url_expansions_str, int *num_expansions);
00864 
00865   static void *cluster_delta_cb(void *opaque_token, char *data_raw, int data_len);
00866 
00867 public:
00868   static int m_id;
00869   static HttpConfigParams m_master;
00870   static HttpUserAgent_RegxEntry *user_agent_list;
00871 };
00872 
00873 // DI's request to disable ICP on the fly
00874 extern volatile int32_t icp_dynamic_enabled;
00875 
00876 /////////////////////////////////////////////////////////////
00877 /////////////////////////////////////////////////////////////
00878 //
00879 //  inline functions
00880 //
00881 /////////////////////////////////////////////////////////////
00882 /////////////////////////////////////////////////////////////
00883 inline
00884 HttpConfigParams::HttpConfigParams()
00885   : proxy_hostname(NULL),
00886     proxy_hostname_len(0),
00887     server_max_connections(0),
00888     origin_min_keep_alive_connections(0),
00889     parent_proxy_routing_enable(0),
00890     disable_ssl_parenting(0),
00891     enable_url_expandomatic(0),
00892     no_dns_forward_to_parent(0),
00893     uncacheable_requests_bypass_parent(1),
00894     no_origin_server_dns(0),
00895     use_client_target_addr(0),
00896     use_client_source_port(0),
00897     proxy_request_via_string(NULL),
00898     proxy_request_via_string_len(0),
00899     proxy_response_via_string(NULL),
00900     proxy_response_via_string_len(0),
00901     url_expansions_string(NULL),
00902     url_expansions(NULL),
00903     num_url_expansions(0),
00904     session_auth_cache_keep_alive_enabled(1),
00905     transaction_active_timeout_in(900),
00906     accept_no_activity_timeout(120),
00907     parent_connect_attempts(4),
00908     per_parent_connect_attempts(2),
00909     parent_connect_timeout(30),
00910     anonymize_other_header_list(NULL),
00911     enable_http_stats(1),
00912     icp_enabled(0),
00913     stale_icp_enabled(0),
00914     cache_vary_default_text(NULL),
00915     cache_vary_default_images(NULL),
00916     cache_vary_default_other(NULL),
00917     max_cache_open_write_retries(1),
00918     cache_enable_default_vary_headers(0),
00919     cache_post_method(0),
00920     connect_ports_string(NULL),
00921     connect_ports(NULL),
00922     push_method_enabled(0),
00923     referer_filter_enabled(0),
00924     referer_format_redirect(0),
00925     reverse_proxy_enabled(0),
00926     url_remap_required(1),
00927     record_cop_page(0),
00928     errors_log_error_pages(1),
00929     enable_http_info(0),
00930     cluster_time_delta(0),
00931     redirection_enabled(0),
00932     redirection_host_no_port(0),
00933     number_of_redirections(1),
00934     post_copy_size(2048),
00935     ignore_accept_mismatch(0),
00936     ignore_accept_language_mismatch(0),
00937     ignore_accept_encoding_mismatch(0),
00938     ignore_accept_charset_mismatch(0),
00939     send_100_continue_response(0),
00940     autoconf_port(0),
00941     autoconf_localhost_only(0)
00942 {
00943 }
00944 
00945 inline
00946 HttpConfigParams::~HttpConfigParams()
00947 {
00948   ats_free(proxy_hostname);
00949   ats_free(proxy_request_via_string);
00950   ats_free(proxy_response_via_string);
00951   ats_free(url_expansions_string);
00952   ats_free(anonymize_other_header_list);
00953   ats_free(oride.proxy_response_server_string);
00954   ats_free(oride.global_user_agent_header);
00955   ats_free(cache_vary_default_text);
00956   ats_free(cache_vary_default_images);
00957   ats_free(cache_vary_default_other);
00958   ats_free(connect_ports_string);
00959   ats_free(reverse_proxy_no_host_redirect);
00960   ats_free(url_expansions);
00961 
00962   if (connect_ports) {
00963     delete connect_ports;
00964   }
00965 }
00966 #endif /* #ifndef _HttpConfig_h_ */

Generated by  doxygen 1.7.1