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

HttpTransactHeaders.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 #if !defined (_HttpTransactHeaders_h_)
00025 #define _HttpTransactHeaders_h_
00026 
00027 #define ink_time_t time_t
00028 
00029 extern int nstrhex(char *d, unsigned int i);
00030 
00031 class HttpTransactHeaders
00032 {
00033 public:
00034   static bool is_this_http_method_supported(int method);
00035   static bool is_method_cacheable(const HttpConfigParams *http_config_param, const int method);
00036   static bool is_method_cache_lookupable(int method);
00037   static bool is_this_a_hop_by_hop_header(const char *field_name_wks);
00038   static bool is_this_method_supported(int the_scheme, int the_method);
00039 
00040   static void insert_supported_methods_in_response(HTTPHdr * response, int the_scheme);
00041 
00042   static void build_base_response(HTTPHdr * outgoing_response, HTTPStatus status,
00043                                   const char *reason_phrase, int reason_phrase_len, ink_time_t date);
00044 
00045   static void copy_header_fields(HTTPHdr * src_hdr, HTTPHdr * new_hdr,
00046                                  bool retain_proxy_auth_hdrs, ink_time_t date = 0);
00047 
00048   static void convert_request(HTTPVersion outgoing_ver, HTTPHdr * outgoing_request);
00049   static void convert_response(HTTPVersion outgoing_ver, HTTPHdr * outgoing_response);
00050   static void convert_to_0_9_request_header(HTTPHdr * outgoing_request);
00051   static void convert_to_1_0_request_header(HTTPHdr * outgoing_request);
00052   static void convert_to_1_1_request_header(HTTPHdr * outgoing_request);
00053   static void convert_to_0_9_response_header(HTTPHdr * outgoing_response);
00054   static void convert_to_1_0_response_header(HTTPHdr * outgoing_response);
00055   static void convert_to_1_1_response_header(HTTPHdr * outgoing_response);
00056 
00057   static ink_time_t calculate_document_age(ink_time_t request_time, ink_time_t response_time,
00058                                            HTTPHdr * base_response, ink_time_t base_response_date, ink_time_t now);
00059   static bool does_server_allow_response_to_be_stored(HTTPHdr * resp);
00060   static bool downgrade_request(bool * origin_server_keep_alive, HTTPHdr * outgoing_request);
00061 
00062   static void generate_and_set_squid_codes(HTTPHdr * header, char *via_string,
00063                                           HttpTransact::SquidLogInfo * squid_codes);
00064 
00065   // Removing handle_conditional_headers.  Functionality appears to be elsewhere (issue_revalidate)
00066   // and the only condition when it does anything causes an assert to go 
00067   // off
00068   // static void handle_conditional_headers(HttpTransact::CacheLookupInfo * cache_info, HTTPHdr * header);
00069   static void insert_warning_header(HttpConfigParams *http_config_param,
00070                                     HTTPHdr *header, HTTPWarningCode code,
00071                                     const char *warn_text = NULL, int warn_text_len = 0);
00072   static void insert_time_and_age_headers_in_response(ink_time_t request_sent_time,
00073                                                       ink_time_t response_received_time,
00074                                                       ink_time_t now, HTTPHdr * base, HTTPHdr * outgoing);
00075   static void insert_server_header_in_response(const char *server_tag, int server_tag_size, HTTPHdr * header);
00076   static void insert_via_header_in_request(HttpTransact::State *s, HTTPHdr *header);
00077   static void insert_via_header_in_response(HttpTransact::State *s, HTTPHdr *header);
00078   static void insert_hsts_header_in_response(HttpTransact::State *s, HTTPHdr *header);
00079 
00080   static bool is_request_proxy_authorized(HTTPHdr * incoming_hdr);
00081 
00082   static void insert_basic_realm_in_proxy_authenticate(const char *realm, HTTPHdr * header, bool bRevPrxy);
00083 
00084   static void remove_conditional_headers(HTTPHdr * outgoing);
00085   static void remove_100_continue_headers(HttpTransact::State *s, HTTPHdr * outgoing);
00086   static void remove_host_name_from_url(HTTPHdr * outgoing_request);
00087   static void add_global_user_agent_header_to_request(OverridableHttpConfigParams *http_txn_conf, HTTPHdr * header);
00088   static void add_server_header_to_response(OverridableHttpConfigParams *http_txn_conf, HTTPHdr * header);
00089   static void remove_privacy_headers_from_request(HttpConfigParams *http_config_param,
00090                                                   OverridableHttpConfigParams *http_txn_conf, HTTPHdr * header);
00091 
00092   static int nstrcpy(char *d, const char *as);
00093 };
00094 
00095 
00096 /*****************************************************************************
00097  *****************************************************************************
00098  ****                                                                     ****
00099  ****                     Inline Utility Routines                         ****
00100  ****                                                                     ****
00101  *****************************************************************************
00102  *****************************************************************************/
00103 inline bool
00104 HttpTransactHeaders::is_this_http_method_supported(int method)
00105 {
00106   return ((method == HTTP_WKSIDX_GET) ||
00107           (method == HTTP_WKSIDX_POST) ||
00108           (method == HTTP_WKSIDX_CONNECT) ||
00109           (method == HTTP_WKSIDX_DELETE) ||
00110           (method == HTTP_WKSIDX_PURGE) ||
00111           (method == HTTP_WKSIDX_HEAD) ||
00112           (method == HTTP_WKSIDX_OPTIONS) ||
00113           (method == HTTP_WKSIDX_PUT) || (method == HTTP_WKSIDX_PUSH) || (method == HTTP_WKSIDX_TRACE));
00114 }
00115 
00116 inline int
00117 HttpTransactHeaders::nstrcpy(char *d, const char *as)
00118 {
00119   const char *s = as;
00120   while (*s)
00121     *d++ = *s++;
00122   return s - as;
00123 }
00124 
00125 
00126 ///////////////////////////////////////////////////////////////////////////////
00127 // Name       : is_request_proxy_authorized
00128 // Description: does request authorization meet our authentication requirement
00129 //
00130 // Input      :
00131 // Output     :
00132 //
00133 // Details    :
00134 //   Currently a place holder.
00135 inline bool
00136 HttpTransactHeaders::is_request_proxy_authorized(HTTPHdr * incoming_hdr)
00137 {
00138   ink_assert(incoming_hdr);
00139   // TODO: What do we need to do here?
00140   return true;
00141 }
00142 
00143 #endif

Generated by  doxygen 1.7.1