Diff for /parser3/src/main/pa_request.C between versions 1.38 and 1.42

version 1.38, 2001/03/15 11:00:41 version 1.42, 2001/03/18 11:58:20
Line 27  Request::Request(Pool& apool, Line 27  Request::Request(Pool& apool,
                                  Info& ainfo,                                   Info& ainfo,
                                  String::Untaint_lang alang) : Pooled(apool),                                   String::Untaint_lang alang) : Pooled(apool),
         stack(apool),          stack(apool),
         root_class(apool),          ROOT(apool),
         env_class(apool),          env(apool),
         form_class(apool),          form(apool),
           request(apool, *this),
           response(apool),
         fclasses(apool),          fclasses(apool),
         flang(alang),          flang(alang),
         info(ainfo)          info(ainfo)
Line 37  Request::Request(Pool& apool, Line 39  Request::Request(Pool& apool,
         // root superclass,           // root superclass, 
         //   parent of all classes,           //   parent of all classes, 
         //   operators holder          //   operators holder
         initialize_root_class(pool(), root_class);          initialize_root_class(pool(), ROOT);
         classes().put(*root_class_name, &root_class);          classes().put(*root_class_name, &ROOT);
         // table class          // table class
         classes().put(*table_class_name, table_class);            classes().put(*table_class_name, table_class);  
 //      table_class->set_name(*table_class_name);  //      table_class->set_name(*table_class_name);
   
         // env class          // env class
         classes().put(*env_class_name, &env_class);          classes().put(*env_class_name, &env);
         // form class          // form class
         classes().put(*form_class_name, &form_class);             classes().put(*form_class_name, &form); 
           // request class
           classes().put(*request_class_name, &request);   
           // response class
           classes().put(*response_class_name, &response); 
 }  }
   
 char *Request::core(const char *sys_auto_path1,  void Request::core(Exception& system_exception,
                                         const char *sys_auto_path2) {                                     const char *sys_auto_path1,
         char *result;                                     const char *sys_auto_path2) {
         VStateless_class *main_class=0;          VStateless_class *main_class=0;
           bool need_rethrow=false;  Exception rethrow_me;
         TRY {          TRY {
                 char *auto_filespec=(char *)malloc(MAX_STRING);                  char *auto_filespec=(char *)malloc(MAX_STRING);
                                   
Line 81  char *Request::core(const char *sys_auto Line 88  char *Request::core(const char *sys_auto
                                 main_class_name, main_class);                                  main_class_name, main_class);
                 }                  }
   
                   Value *element;
                 // $MAIN:limits hash used here,                  // $MAIN:limits hash used here,
                 //      until someone with less privileges have overriden them                  //      until someone with less privileges have overriden them
                 Value *limits=main_class?main_class->get_element(*limits_name):0;                  Value *limits=main_class?main_class->get_element(*limits_name):0;
                 Value *element;  
                 // $limits.post_max_size default 10M                  // $limits.post_max_size default 10M
                 element=limits?limits->get_element(*post_max_size_name):0;                  element=limits?limits->get_element(*post_max_size_name):0;
                 int value=element?(size_t)element->get_double():0;                  int value=element?(size_t)element->get_double():0;
                 int post_max_size=value?value:10*0x400*400;                  int post_max_size=value?value:10*0x400*400;
   
                 form_class.fill_fields(*this, post_max_size);                  //response.fields().put(*content_type_name, TODO);
   
                   form.fill_fields(*this, post_max_size);
   
                 // TODO: load site auto.p files, all assigned bases from upper dir                  // TODO: load site auto.p files, all assigned bases from upper dir
                 char *site_auto_file="Y:\\parser3\\src\\auto.p";                  /*char *site_auto_file="Y:\\parser3\\src\\auto.p";
                 main_class=use_file(                  main_class=use_file(
                         site_auto_file, false/*ignore possible read problem*/,                          site_auto_file, false/*ignore possible read problem* /,
                         main_class_name, main_class);                          main_class_name, main_class);*/
   
                   // $MAIN:defaults
                   Value *defaults=main_class?main_class->get_element(*defaults_name):0;
                   // $defaults.content-type
                   element=defaults?defaults->get_element(*content_type_name):0;
                   if(element)
                           response.fields().put(*content_type_name, element);
   
                 // there must be some auto.p                  // there must be some auto.p
                 if(!main_class)                  if(!main_class)
Line 109  char *Request::core(const char *sys_auto Line 125  char *Request::core(const char *sys_auto
                         main_class_name, main_class);                          main_class_name, main_class);
   
                 // execute @main[]                  // execute @main[]
                 result=execute_method(*main_class, *main_method_name);                  const String *body_string=execute_method(*main_class, *main_method_name);
                 if(!result)                  if(!body_string)
                         THROW(0,0,                          THROW(0,0,
                         0,                           0, 
                         "'"MAIN_METHOD_NAME"' method not found");                          "'"MAIN_METHOD_NAME"' method not found");
   
                   // store 'body' unless response already have one
                   response.fields().put_dont_replace(*body_name, NEW VString(*body_string));
         }           } 
         CATCH(e) {          CATCH(e) {
                 TRY {                  TRY {
                         // we're returning not result, but error explanation                          // we're returning not result, but error explanation
                         result=0;                          const String *body_string=0;
                                                   
                         if(main_class) { // we've managed to end up with some main_class                          if(main_class) { // we've managed to end up with some main_class
                                 // maybe we'd be lucky enough as to report an error                                  // maybe we'd be lucky enough as to report an error
Line 140  char *Request::core(const char *sys_auto Line 159  char *Request::core(const char *sys_auto
                                                                 const Origin& origin=problem_source->origin();                                                                  const Origin& origin=problem_source->origin();
                                                                 if(origin.file) {                                                                  if(origin.file) {
                                                                         char *buf=(char *)malloc(MAX_STRING);                                                                          char *buf=(char *)malloc(MAX_STRING);
                                                                         snprintf(buf, MAX_STRING, "%s(%d): ",                                                                           snprintf(buf, MAX_STRING, "%s(%d):", 
                                                                                 origin.file, 1+origin.line);                                                                                  origin.file, 1+origin.line);
                                                                         String *NEW_STRING(origin_file_line, buf);                                                                          String *NEW_STRING(origin_file_line, buf);
                                                                         origin_value=NEW VString(*origin_file_line);                                                                          origin_value=NEW VString(*origin_file_line);
Line 182  char *Request::core(const char *sys_auto Line 201  char *Request::core(const char *sys_auto
                                                                 code_value=NEW VUnknown(pool());                                                                  code_value=NEW VUnknown(pool());
                                                         frame.store_param(code_name, code_value);                                                          frame.store_param(code_name, code_value);
   
                                                         result=execute_method(frame, *method);                                                          {
                                                                   Temp_lang temp_lang(*this, 
                                                                           String::Untaint_lang::HTML_TYPO);
                                                                   body_string=execute_method(frame, *method);
                                                           }
                                                 }                                                  }
                         }                          }
                                                   
                         // couldn't report an error beautifully, doing that ugly                          if(!body_string) {  // couldn't report an error beautifully?
                         if(!result) {                                  // doing that ugly
                                 result=(char *)malloc(MAX_STRING);  
                                 result[0]=0;                                  // assign content-type
                                   String &content_type_value=*NEW String(pool());
                                   content_type_value.APPEND_CONST("text/plain");
                                   response.fields().put(*content_type_name, 
                                           NEW VString(content_type_value));
   
                                   // make up result: $origin $source $comment $type $code
                                   char *buf=(char *)malloc(MAX_STRING);
                                 size_t printed=0;                                  size_t printed=0;
                                 const String *problem_source=e.problem_source();                                  const String *problem_source=e.problem_source();
                                 if(problem_source) {                                  if(problem_source) {
 #ifndef NO_STRING_ORIGIN  #ifndef NO_STRING_ORIGIN
                                         const Origin& origin=problem_source->origin();                                          const Origin& origin=problem_source->origin();
                                         if(origin.file)                                          if(origin.file)
                                                 printed+=snprintf(result+printed, MAX_STRING-printed, "%s(%d): ",                                                   printed+=snprintf(buf+printed, MAX_STRING-printed, "%s(%d): ", 
                                                 origin.file, 1+origin.line);                                                  origin.file, 1+origin.line);
 #endif  #endif
                                         printed+=snprintf(result+printed, MAX_STRING-printed, "'%s' ",                                           printed+=snprintf(buf+printed, MAX_STRING-printed, "'%s' ", 
                                                 problem_source->cstr());                                                  problem_source->cstr());
                                 }                                  }
                                 printed+=snprintf(result+printed, MAX_STRING-printed, "%s",                                   printed+=snprintf(buf+printed, MAX_STRING-printed, "%s", 
                                         e.comment());                                          e.comment());
                                 const String *type=e.type();                                  const String *type=e.type();
                                 if(type) {                                  if(type) {
                                         printed+=snprintf(result+printed, MAX_STRING-printed, "  type: %s",                                           printed+=snprintf(buf+printed, MAX_STRING-printed, "  type: %s", 
                                                 type->cstr());                                                  type->cstr());
                                         const String *code=e.code();                                          const String *code=e.code();
                                         if(code)                                          if(code)
                                                 printed+=snprintf(result+printed, MAX_STRING-printed, ", code: %s",                                                   printed+=snprintf(buf+printed, MAX_STRING-printed, ", code: %s", 
                                                 code->cstr());                                                  code->cstr());
                                 }                                  }
                                   String *error_string=NEW String(pool()); error_string->APPEND_CONST(buf);
                                   body_string=error_string;
                         }                          }
   
                           // store 'body' overwriting any response already had
                           response.fields().put(*body_name, NEW VString(*body_string));
                 }                  }
                 CATCH(e) {                  CATCH(e) {
                         // exception in exception handler occured                          // exception in request exception handler
                         // probably totally out of memory                          // remember to rethrow it
                         // can't say anything about such sad story                          rethrow_me=e;  need_rethrow=true; 
                         // would just return 0  
                         result=0;  
                 }                  }
                 END_CATCH                  END_CATCH
         }          }
         END_CATCH          END_CATCH // do not use pool() after this point - no exception handler set
                     // any throw() would try to use zero exception() pointer 
   
           if(need_rethrow) // there were an exception set for us to rethrow?
                   system_exception._throw(rethrow_me.type(), rethrow_me.code(),
                           rethrow_me.problem_source(),
                           rethrow_me.comment());
   
         return result;  
 }  }
   
 VStateless_class *Request::use_file(  VStateless_class *Request::use_file(
Line 280  char *Request::absolute(const char *name Line 318  char *Request::absolute(const char *name
                 strcat(result, name);                  strcat(result, name);
                 return result;                  return result;
         } else           } else 
                 return relative(info.request_uri, name);                  return relative(info.uri, name);
 }  }

Removed from v.1.38  
changed lines
  Added in v.1.42


E-mail: