OSDN Git Service

bug fix.
authorvisor <visor@users.sourceforge.jp>
Tue, 2 Jun 2015 12:07:39 +0000 (21:07 +0900)
committervisor <visor@users.sourceforge.jp>
Tue, 2 Jun 2015 12:07:39 +0000 (21:07 +0900)
modules/ml-neon.cc

index a4e9246..e4af960 100644 (file)
@@ -385,10 +385,9 @@ void  NeonQuery::submit () {
        if (! rawquery.isEmpty ()) {
            setRawQuery (fd);
        } else {
-           ustring  data;
-           buildQuery (queryParam (), data);
-           setFormType_urlencoded ();
-           ne_set_request_body_buffer (req, data.c_str (), data.size ());
+           rawquery.setText ();
+           buildQuery (queryParam (), rawquery.param);
+           setRawQuery (fd);
        }
        break;
     case METHOD_FILE:
@@ -748,7 +747,7 @@ void  NeonQuery::setRawQuery (FileMacro& fd) {
 void  MLNeon::newSession (MlEnv* mlenv) {
     session.reset (new NeonSession (proto, host, port));
     // *** User-Agent
-    query.reset (new NeonQuery (session->get (), mlenv));
+//    query.reset (new NeonQuery (session->get (), mlenv));
 }
 
 //============================================================
@@ -952,6 +951,7 @@ MNode*  ml_neon_http_request (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
        {NULL, 0, 0}
     };
 
+    obj->query.reset (new NeonQuery (obj->session->get (), mlenv));
     setParams (arg, 1, &params, kwlist, &keywords, NULL);
     obj->query->path = eval_str (params[0], mlenv);
     if (evkw_bool (0, f))      // 0:get
@@ -1034,6 +1034,8 @@ MNode*  ml_neon_http_status (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     
     if (arg)
        throw (uErrorWrongNumber);
+    if (! obj->query)
+       return NULL;
 
     return newMNode_num (obj->query->getStatus ());
 }
@@ -1051,6 +1053,8 @@ MNode*  ml_neon_http_response (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
     if (arg)
        throw (uErrorWrongNumber);
+    if (! obj->query)
+       return NULL;
 
     std::stringstream  ostr;
     MotorOutputOStream  out (&ostr);
@@ -1076,6 +1080,8 @@ MNode*  ml_neon_http_response_file (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     nextNode (arg);
     if (arg)
        throw (uErrorWrongNumber);
+    if (! obj->query)
+       return NULL;
 
     tgt = mlenv->env->path_store_file (name);
     tmp.assign (tgt).append (CharConst ("-tmp")).append (to_ustring (getpid ()));
@@ -1110,6 +1116,8 @@ MNode*  ml_neon_http_response_output (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     setParams (arg, 0, NULL, kwlist, &keywords, NULL);
     if (keywords[0] && eval_bool (keywords[0], mlenv))
        cflag = true;
+    if (! obj->query)
+       return NULL;
 
     if (! mlenv->env->responseDone)
        mlenv->env->standardResponse_html ();
@@ -1138,6 +1146,8 @@ MNode*  ml_neon_get_cookie (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     nextNode (arg);
     if (arg)
        throw (uErrorWrongNumber);
+    if (! obj->query)
+       return NULL;
 
     ustring  ans = obj->query->getResponseCookie (name);
     if (ans.length () > 0) {
@@ -1159,6 +1169,8 @@ MNode*  ml_neon_get_cookie_all (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
     if (arg)
        throw (uErrorWrongNumber);
+    if (! obj->query)
+       return NULL;
 
     return obj->query->getResponseCookieAll ();
 }
@@ -1172,8 +1184,11 @@ MNode*  ml_neon_get_cookie_all (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 MNode*  ml_neon_http_content_type (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     MNode*  arg = cell->cdr ();
     MLNeon*  obj = (MLNeon*)mobj;
-    ustring  u = obj->query->getResponseHeader ("content-type");
 
+    if (! obj->query)
+       return NULL;
+
+    ustring  u = obj->query->getResponseHeader ("content-type");
     if (u.length () > 0) {
        uiterator  b, e, m;
        b = u.begin ();
@@ -1206,6 +1221,8 @@ MNode*  ml_neon_http_get_header (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     nextNode (arg);
     if (arg)
        throw (uErrorWrongNumber);
+    if (! obj->query)
+       return NULL;
 
     u = obj->query->getResponseHeader (name.c_str ());
     if (u.length () > 0) {
@@ -1227,6 +1244,8 @@ MNode*  ml_neon_http_get_header_all (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
     if (arg)
        throw (uErrorWrongNumber);
+    if (! obj->query)
+       return NULL;
 
     return obj->query->getResponseHeaderAll ();
 }