OSDN Git Service

set-cookie function.
authorvisor <visor@users.sourceforge.jp>
Tue, 13 Jul 2010 12:30:54 +0000 (21:30 +0900)
committervisor <visor@users.sourceforge.jp>
Tue, 13 Jul 2010 12:30:54 +0000 (21:30 +0900)
lib/http.cc
lib/motorenv.cc
ml/main.cc
modules/ml-apache.cc
modules/ml-apache.h
wiki/wikiformat.cc
wiki/wikiline.cc

index 4d76a58..9527ca0 100644 (file)
@@ -39,7 +39,7 @@ void  HTTPResponse::setCookie (const ustring& key, const ustring& val, const ust
     umatch  m;
     static uregex  re ("//|/\\.|\\.\\.|[\\x00-\\x20\\x7f-\\xff]");
     
-    if (key.size () < 128 && val.size () < 512) {
+    if (key.size () <= 128 && val.size () <= 512) {
        ck = cookieencode (key);
        ck.append (uEq);
        ck.append (cookieencode (val));
index 211cc04..23afefe 100644 (file)
@@ -260,7 +260,6 @@ void  MotorEnv::setDefault () {
        break;
     case CGIForm::M_NONE:
        htmlFile = appenv->getHtml;
-//     *log << "REQUEST_METHOD not defined.\n";
        break;
     }
     errorHtmlFile = appenv->errorHtml;
@@ -329,7 +328,7 @@ void  MotorEnv::doML () {
        }
        break;
     default:
-       *log << "REQUEST_METHOD not defined.\n";
+//     *log << "REQUEST_METHOD not defined.\n";
        doML (appenv->getML);
     }
 }
index 11b259d..558eb71 100644 (file)
@@ -44,10 +44,13 @@ int  main (int argc, char** argv) {
        if (aenv.debugDump) {
            close (2);
            dup (1);
-//         env.standardResponse (ustring (kMIME_TEXT), ustring (kCODE_UTF8));
-           env.standardResponse (ustring (kMIME_TEXT), uUTF8, uEmpty, false);
-           cout.flush ();
-           cerr.flush ();
+           if (form->method != CGIForm::M_NONE) {
+               env.standardResponse (ustring (kMIME_TEXT), uUTF8, uEmpty, false);
+               cout.flush ();
+               cerr.flush ();
+           } else {
+               env.responseDone = true;
+           }
        }
 
 #ifdef DEBUG
index c602119..9c476e9 100644 (file)
@@ -248,3 +248,52 @@ MNode*  ml_read_cookie (MNode* cell, MlEnv* mlenv) {
     }
     return newMNode_str (new ustring (val));
 }
+
+/*DOC:
+===set-cookie===
+ (set-cookie NAME VALUE [:path PATH] [:domain DOMAIN] [:span TIME] [:limit TIME]) -> NIL
+
+*/
+//#AFUNC       set-cookie      ml_set_cookie
+MNode*  ml_set_cookie (MNode* cell, MlEnv* mlenv) {
+    MNode*  arg = cell->cdr ();
+    ustring  name;
+    ustring  value;
+    ustring  path;
+    ustring  domain;
+    time_t  span = 0;
+    time_t  limit = 0;
+    bool  fsecure = false;
+    std::vector<MNode*>  params;
+    std::vector<MNode*>  keywords;
+    static paramList  kwlist[] = {
+       {CharConst ("path"), false},
+       {CharConst ("domain"), false},
+       {CharConst ("span"), false},
+       {CharConst ("limit"), false},
+       {CharConst ("secure"), true},
+       {NULL, 0, 0}
+    };
+
+    setParams (arg, 2, &params, kwlist, &keywords, NULL);
+    name = eval_asciiword (params[0], mlenv);
+    value = eval_str (params[1], mlenv);
+    if (keywords[0])
+       path = eval_asciiword (keywords[0], mlenv);
+    if (keywords[1])
+       domain = eval_asciiword (keywords[1], mlenv);
+    if (keywords[2])
+       span = eval_int (keywords[2], mlenv);
+    if (keywords[3])
+       limit = eval_int (keywords[3], mlenv);
+    if (keywords[4])
+       fsecure = eval_bool (keywords[4], mlenv);
+    if (name.length () > 128)
+       throw ("too long name.");
+    if (value.length () > 512)
+       throw ("too long value.");
+
+    mlenv->env->http.setCookie (name, value, path, span, domain, fsecure, mlenv->env);
+
+    return NULL;
+}
index 9a8c7b8..7d2ede5 100644 (file)
@@ -21,5 +21,6 @@ MNode*  ml_is_get_method (MNode* cell, MlEnv* mlenv);
 MNode*  ml_is_post_method (MNode* cell, MlEnv* mlenv);
 MNode*  ml_absolute_url (MNode* cell, MlEnv* mlenv);
 MNode*  ml_read_cookie (MNode* cell, MlEnv* mlenv);
+MNode*  ml_set_cookie (MNode* cell, MlEnv* mlenv);
 
 #endif /* ML_APACHE_H */
index f99f1df..ecfe180 100644 (file)
@@ -1,4 +1,5 @@
 #include "wikiformat.h"
+#include "config.h"
 #include "wikiline.h"
 #include "wikitable.h"
 #include "wikicmd.h"
@@ -15,7 +16,7 @@
 #include "ustring.h"
 #include <boost/ptr_container/ptr_vector.hpp>
 
-#define TABLECOMPATFLAG        1
+// config.h <-- #define TABLECOMPATFLAG        1
 
 #define  kComment      "//"
 #define  kWikiP                '^'
index 3a601d5..e4671d4 100644 (file)
@@ -112,9 +112,6 @@ static bool  wl_http_sub (bool newwin, WikiMotorObjVecVec* args, WikiMotorObjVec
        if (fscript) {
            attrib.onclick = url + attrib.onclick;
            out->out_raw (CharConst (" href=\"#\""));
-//         out->out_raw (CharConst (" href=\"#\" onClick=\""))
-//             ->out_toHTML_noCtrl (url)
-//             ->out_raw (uQ2);
        } else {
            wiki->outputName (out, CharConst ("href"), url, false);
        }