Diff for /parser3/src/main/pa_request.C between versions 1.77 and 1.83

version 1.77, 2001/03/24 15:58:01 version 1.83, 2001/03/27 15:37:52
Line 17 Line 17
 #include "pa_vclass.h"  #include "pa_vclass.h"
 #include "_root.h"  #include "_root.h"
 #include "_table.h"  #include "_table.h"
   #include "_file.h"
 #include "pa_globals.h"  #include "pa_globals.h"
 #include "pa_vint.h"  #include "pa_vint.h"
 #include "pa_vmframe.h"  #include "pa_vmframe.h"
 #include "pa_types.h"  #include "pa_types.h"
   #include "pa_vtable.h"
   
 /// $limits.post_max_size default 10M  /// $limits.post_max_size default 10M
 const size_t MAX_POST_SIZE_DEFAULT=10*0x400*400;  const size_t MAX_POST_SIZE_DEFAULT=10*0x400*400;
   
   /// content type of exception response, when no @MAIN:exception handler defined
   const char *UNHANDLED_EXCEPTION_CONTENT_TYPE="text/plain";
   
   /// content type of response when no $MAIN:defaults.content-type defined
   const char *DEFAULT_CONTENT_TYPE="text/html";
   
 //  //
 Request::Request(Pool& apool,  Request::Request(Pool& apool,
                                  Info& ainfo,                                   Info& ainfo,
Line 49  Request::Request(Pool& apool, Line 57  Request::Request(Pool& apool,
         classes().put(*root_class_name, &ROOT);          classes().put(*root_class_name, &ROOT);
         // table class          // table class
         classes().put(*table_class_name, table_class);            classes().put(*table_class_name, table_class);  
           // file class
           classes().put(*file_class_name, file_class);    
         // env class          // env class
         classes().put(*env_class_name, &env);          classes().put(*env_class_name, &env);
         // form class          // form class
Line 105  void Request::core(const char *root_auto Line 114  void Request::core(const char *root_auto
   
                 // $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 *element;                          Value *limits=main_class?main_class->get_element(*limits_name):0;
                 // $limits.post_max_size default 10M                          // $limits.post_max_size default 10M
                 element=limits?limits->get_element(*post_max_size_name):0;                          Value *element=limits?limits->get_element(*post_max_size_name):0;
                 size_t value=element?(size_t)element->get_double():0;                          size_t value=element?(size_t)element->get_double():0;
                 size_t post_max_size=value?value:MAX_POST_SIZE_DEFAULT;                          size_t post_max_size=value?value:MAX_POST_SIZE_DEFAULT;
                           
                           form.fill_fields(*this, post_max_size);
                   }
   
                 form.fill_fields(*this, post_max_size);                  // filling cookies
                 cookie.fill_fields(*this);                  cookie.fill_fields(*this);
   
                 // loading site auto.p                  // loading site auto.p
Line 132  void Request::core(const char *root_auto Line 144  void Request::core(const char *root_auto
                         /* /document/root */                          /* /document/root */
                         char *file_spec=                          char *file_spec=
                                 (char *)malloc(strlen(info.path_translated)+strlen(AUTO_FILE_NAME)+1);                                  (char *)malloc(strlen(info.path_translated)+strlen(AUTO_FILE_NAME)+1);
                         strcpy(file_spec, info.document_root);                          size_t document_root_size=strlen(info.document_root);
                           if(info.document_root[document_root_size-1]=='/')
                                   document_root_size--;
                           memcpy(file_spec, info.document_root, document_root_size);
   
                         /* /requested/file.html */                          /* /requested/file.html */
                         char *branches=(char *)malloc(strlen(info.path_translated)+1);                          char *branches=(char *)malloc(strlen(info.path_translated)+1);
                         strcpy(branches, info.path_translated+strlen(info.document_root));                          strcpy(branches, info.path_translated+document_root_size);
                         char *next=branches;                          char *next=branches;
                           char *append_here=file_spec+document_root_size;
   
                         char *append_here=file_spec+strlen(file_spec);  
                         size_t slash_auto_p_size=strlen("/" AUTO_FILE_NAME);                          size_t slash_auto_p_size=strlen("/" AUTO_FILE_NAME);
                         while(true) {                          while(true) {
                                 char *step=lsplit(&next, '/');                                  char *step=lsplit(&next, '/');
Line 166  void Request::core(const char *root_auto Line 181  void Request::core(const char *root_auto
                         main_class_name, main_class);                          main_class_name, main_class);
   
                 // $MAIN:defaults                  // $MAIN:defaults
                 Value *defaults=main_class?main_class->get_element(*defaults_name):0;                  Value *defaults=main_class->get_element(*defaults_name);
                 // value must be allocated on request's pool for that pool used on                  // value must be allocated on request's pool for that pool used on
                 // meaning constructing @see attributed_meaning_to_string                  // meaning constructing @see attributed_meaning_to_string
                 default_content_type=defaults?                  default_content_type=defaults?defaults->get_element(*content_type_name):0;
                         defaults->get_element(*content_type_name)                  if(Value *element=main_class->get_element(*html_typo_name))
                         :NEW VString(*NEW String(pool(), "text/html"));                          if(VTable *vtable=element->get_vtable())
                                   pool().set_tag(&vtable->table());
   
                 // execute @main[]                  // execute @main[]
                 const String *body_string=execute_method(*main_class, *main_method_name);                  const String *body_string=execute_method(*main_class, *main_method_name);
Line 180  void Request::core(const char *root_auto Line 196  void Request::core(const char *root_auto
                         0,                           0, 
                         "'"MAIN_METHOD_NAME"' method not found");                          "'"MAIN_METHOD_NAME"' method not found");
   
                   // post-process
                   // todo
   
                 // extract response body                  // extract response body
                 Value *body_value=static_cast<Value *>(                  Value *body_value=static_cast<Value *>(
                         response.fields().get(*body_name));                          response.fields().get(*body_name));
Line 335  void Request::core(const char *root_auto Line 354  void Request::core(const char *root_auto
   
                                 // future $response:content-type                                  // future $response:content-type
                                 response.fields().put(*content_type_name,                                   response.fields().put(*content_type_name, 
                                         NEW VString(*NEW String(pool(), "text/plain")));                                          NEW VString(*NEW String(pool(), UNHANDLED_EXCEPTION_CONTENT_TYPE)));
                                 // future $response:body                                  // future $response:body
                                 body_string=NEW String(pool(), buf);                                  body_string=NEW String(pool(), buf);
                         }                          }
Line 426  void Request::output_result(const String Line 445  void Request::output_result(const String
         cookie.output_result();          cookie.output_result();
                   
         // set default content-type          // set default content-type
         response.fields().put_dont_replace(*content_type_name, default_content_type);          response.fields().put_dont_replace(*content_type_name, 
                   default_content_type?default_content_type
                   :NEW VString(*NEW String(pool(), DEFAULT_CONTENT_TYPE)));
   
         // prepare header: $response:fields without :body          // prepare header: $response:fields without :body
         response.fields().for_each(add_header_attribute, /*excluding*/ body_name);          response.fields().for_each(add_header_attribute, /*excluding*/ body_name);

Removed from v.1.77  
changed lines
  Added in v.1.83


E-mail: