}
#if 0
-void HTTPSend::setMethod (const ustring& _method, bool _fpost) {
- static uregex re ("^(GET|HEAD|POST|OPTIONS|PUT|DELETE|TRACE|PATCH|LINK|UNLINK)$");
- if (checkRe (_method, re)) {
- method = _method;
- fpost = _fpost;
+ustring HTTPQuery::formString (HTTPSend* o) {
+ MNode* e;
+ MNode* a;
+ int c = 0;
+ ustring ans;
+
+ e = params ();
+ if (e && e->isCons ()) {
+ if (o) {
+ while (e) {
+ if (a = e->car ()) {
+ if (c > 0)
+ ans.append (uAmp);
+ ans.append (percentEncode (o->cv (to_string (a->car ()))));
+ if (! isNil (a->cdr ())) {
+ ans.append (uEq);
+ ans.append (percentEncode (o->cv (to_string (a->cdr ()))));
+ }
+ c ++;
+ }
+ nextNode (e);
+ }
+ } else {
+ while (e) {
+ if (a = e->car ()) {
+ if (c > 0)
+ ans.append (uAmp);
+ ans.append (percentEncode (to_string (a->car ())));
+ if (! isNil (a->cdr ())) {
+ ans.append (uEq);
+ ans.append (percentEncode (to_string (a->cdr ())));
+ }
+ c ++;
+ }
+ nextNode (e);
+ }
+ }
}
+ return ans;
}
#endif
assert (0);
}
q.append (uSPC).append (path);
-// if (fpost) {
-// if (method == M_POST) {
switch (method) {
case M_POST:
if (formData)
if (getparams ()) {
q.append (CharConst ("?"));
appendQueryForm (getparams (), q);
+// q.append (getparams.formString (this));
}
break;
case M_PUT:
if (getparams ()) {
q.append (CharConst ("?"));
appendQueryForm (getparams (), q);
+// q.append (getparams.formString (this));
}
break;
default:
if (getparams ()) {
q.append (CharConst ("?"));
appendQueryForm (getparams (), q);
+// q.append (getparams.formString (this));
} else if (params ()) {
q.append (CharConst ("?"));
appendQueryForm (params (), q);
+// q.append (params.formString (this));
}
}
q.append (CharConst (" HTTP/1.0" kCRLF));
for (std::vector<mapelem>::iterator i = header_req.begin (); i < header_req.end (); i ++) {
makeHeader (q, (*i).first, (*i).second);
}
-// if (fpost)
-// if (method == M_POST)
switch (method) {
case M_POST:
if (formData) {
if (c > 0)
u.append (uAmp);
u.append (percentEncode (cv (to_string (a->car ()))));
- u.append (uEq);
- out.write (&*u.begin (), u.length ());
- u.assign (percentEncode (cv (to_string (a->cdr ()))));
+ if (! isNil (a->cdr ())) {
+ u.append (uEq);
+ u.append (percentEncode (cv (to_string (a->cdr ()))));
+ }
out.write (&*u.begin (), u.length ());
c ++;
}
if (c > 0)
out.append (uAmp);
out.append (percentEncode (cv (to_string (a->car ()))));
- out.append (uEq);
- out.append (percentEncode (cv (to_string (a->cdr ()))));
+ if (! isNil (a->cdr ())) {
+ out.append (uEq);
+ out.append (percentEncode (cv (to_string (a->cdr ()))));
+ }
c ++;
}
nextNode (e);
if (e && e->isCons ()) {
while (e) {
if (a = e->car ()) {
- ustring u;
if (c > 0)
- u.append (uAmp);
- u.append (percentEncode (cv (to_string (a->car ()))));
- u.append (uEq);
- ans += u.length ();
- u.assign (percentEncode (cv (to_string (a->cdr ()))));
- ans += u.length ();
+ ans += uAmp.length ();
+ ans += percentEncode (cv (to_string (a->car ()))).length ();
+ if (! isNil (a->cdr ())) {
+ ans += uEq.length ();
+ ans += percentEncode (cv (to_string (a->cdr ()))).length ();
+ }
c ++;
}
nextNode (e);