src/ngx_rewrite_options.cc
// Execute all entries in the script_lines vector, and hand the result off to
// ParseAndSetOptions to obtain the final option values.
Execute all entries in the script_lines vector, and hand the result off to
ParseAndSetOptions to obtain the final option values.
Execute all entries in the script_lines vector and hand the result off to ParseAndSetOptions to obtain the final option values .
bool NgxRewriteOptions::ExecuteScriptVariables(
    ngx_http_request_t* r, MessageHandler* handler,
    NgxRewriteDriverFactory* driver_factory) {
  bool script_error = false;
  if (script_lines_.size() > 0) {
    std::vector<RefCountedPtr<ScriptLine> >::iterator it;
    for (it = script_lines_.begin() ; it != script_lines_.end(); ++it) {
      ScriptLine* script_line = it->get();
      StringPiece args[NGX_PAGESPEED_MAX_ARGS];
      std::vector<ScriptArgIndex*>::iterator cs_it;
      int i;
      for (i = 0; i < script_line->n_args(); i++) {
        args[i] = script_line->args()[i];
      }
      for (cs_it = script_line->data().begin();
           cs_it != script_line->data().end(); cs_it++) {
        ngx_http_script_compile_t* script;
        ngx_array_t* values;
        ngx_array_t* lengths;
        ngx_str_t value;
        script = (*cs_it)->script();
        lengths = *script->lengths;
        values = *script->values;
        if (ngx_http_script_run(r, &value, lengths->elts, 0, values->elts)
            == NULL) {
          handler->Message(kError, "ngx_http_script_run error");
          script_error = true;
          break;
        } else  {
          args[(*cs_it)->index()] = str_to_string_piece(value);
        }
      }
      const char* status = ParseAndSetOptions(args, script_line->n_args(),
          r->pool, handler, driver_factory, script_line->scope(), NULL ,
          ProcessScriptVariablesMode::kOff);
      if (status != NULL) {
        script_error = true;
        handler->Message(kWarning,
            "Error setting option value from script: '%s'", status);
        break;
      }
    }
  }
  if (script_error) {
    handler->Message(kWarning,
        "Script error(s) in configuration, disabling optimization");
    set_enabled(RewriteOptions::kEnabledOff);
    return false;
  }
  return true;
}
bool NgxRewriteOptions :: ExecuteScriptVariables ( ngx_http_request_t * r , MessageHandler * handler , NgxRewriteDriverFactory * driver_factory ) { bool script_error = false ; if ( script_lines_ . size ( ) > 0 ) { std :: vector < RefCountedPtr < ScriptLine > > :: iterator it ; for ( it = script_lines_ . begin ( ) ; it != script_lines_ . end ( ) ; ++ it ) { ScriptLine * script_line = it -> get ( ) ; StringPiece args [ NGX_PAGESPEED_MAX_ARGS ] ; std :: vector < ScriptArgIndex * > :: iterator cs_it ; int i ; for ( i = 0 ; i < script_line -> n_args ( ) ; i ++ ) { args [ i ] = script_line -> args ( ) [ i ] ; } for ( cs_it = script_line -> data ( ) . begin ( ) ; cs_it != script_line -> data ( ) . end ( ) ; cs_it ++ ) { ngx_http_script_compile_t * script ; ngx_array_t * values ; ngx_array_t * lengths ; ngx_str_t value ; script = ( * cs_it ) -> script ( ) ; lengths = * script -> lengths ; values = * script -> values ; if ( ngx_http_script_run ( r , & value , lengths -> elts , 0 , values -> elts ) == NULL ) { handler -> Message ( kError , " " ) ; script_error = true ; break ; } else { args [ ( * cs_it ) -> index ( ) ] = str_to_string_piece ( value ) ; } } const char * status = ParseAndSetOptions ( args , script_line -> n_args ( ) , r -> pool , handler , driver_factory , script_line -> scope ( ) , NULL , ProcessScriptVariablesMode :: kOff ) ; if ( status != NULL ) { script_error = true ; handler -> Message ( kWarning , " " , status ) ; break ; } } } if ( script_error ) { handler -> Message ( kWarning , " " ) ; set_enabled ( RewriteOptions :: kEnabledOff ) ; return false ; } return true ; }
Execute all entries in the script_lines vector, and hand the result off to
ParseAndSetOptions to obtain the final option values.
Execute all entries in the script_lines vector and hand the result off to ParseAndSetOptions to obtain the final option values .
/*cf*/