src/ngx_pagespeed.cc
// Returns false if the header wasn't found.  Otherwise sets cache_control and
// returns true;
Returns false if the header wasn't found.  Otherwise sets cache_control and
returns true.
Returns false if the header wasn ' t found . Otherwise sets cache_control and returns true .
bool ps_get_cache_control(ngx_http_request_t* r, GoogleString* cache_control) {
  auto ccp = static_cast<ngx_table_elt_t**>(r->headers_out.cache_control.elts);
  if (ccp == nullptr) {
    return false;  
  }
  bool first_segment = true;
  for (ngx_uint_t i = 0; i < r->headers_out.cache_control.nelts; i++) {
    if (ccp[i]->hash == 0) {
      continue;  
    }
    if (first_segment) {
      first_segment = false;
    } else {
      cache_control->append(", ");
    }
    cache_control->append(reinterpret_cast<char*>(ccp[i]->value.data),
                          ccp[i]->value.len);
  }
  return true;
}
bool ps_get_cache_control ( ngx_http_request_t * r , GoogleString * cache_control ) { auto ccp = static_cast < ngx_table_elt_t * * > ( r -> headers_out . cache_control . elts ) ; if ( ccp == nullptr ) { return false ; } bool first_segment = true ; for ( ngx_uint_t i = 0 ; i < r -> headers_out . cache_control . nelts ; i ++ ) { if ( ccp [ i ] -> hash == 0 ) { continue ; } if ( first_segment ) { first_segment = false ; } else { cache_control -> append ( " " ) ; } cache_control -> append ( reinterpret_cast < char * > ( ccp [ i ] -> value . data ) , ccp [ i ] -> value . len ) ; } return true ; }
Returns false if the header wasn't found.
Returns false if the header wasn ' t found .
// Use headers_out.cache_control instead of looking for Cache-Control in // headers_out.headers, because if an upstream sent multiple Cache-Control // headers they're already combined in headers_out.cache_control. // Header not present. // Elements with a hash of 0 are marked as excluded.