From 5df79c53745fde5d6c3340a2979b1429cd5892c1 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sat, 8 Oct 2011 20:30:28 +0200 Subject: Initial import of htcd system 1.0 Signed-off-by: Henrik Rydberg --- src/serv/form.cc | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/serv/form.cc (limited to 'src/serv/form.cc') diff --git a/src/serv/form.cc b/src/serv/form.cc new file mode 100644 index 0000000..815f9c4 --- /dev/null +++ b/src/serv/form.cc @@ -0,0 +1,102 @@ +/************************************************************************* + * + * HTCd - Copyright (C) 1998-2006 Henrik Rydberg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +const mstring tag="T."; +const mstring ncookie_tag="ncookie"; +const mstring multipart_tag="multipart"; +const mstring body_tag="T.body"; + +static mstring Tag(const sref& in) +{ + mstring name=in; + for(int i=0;ibody; nb.append(1,' '); nb+=b; + Const(map,s,nb,tok_t::PUBLIC,1); + } + else Const(map,s,b,tok_t::PUBLIC); +} + +static void PushMultipart(tokmap& map,const Mime& root) throw(merror_t) +{ + rpile part; + if(root.Multipart(part)) { + for(int i=0;idata),msg.body); + else if(eqn(msg.cont_trans_enc,trans_quote)) + decodeQP(via(tok->data),msg.body); + else + via(tok->data)<first,tok_t::PUBLIC); + Const(map,val,p->second,tok_t::PUBLIC); + n++; + } + if(req.arg.nempty()) PushWWWForm(map,req.arg); +} + +void envAddForm(tokmap& map,const httpReq& req) +{ + if(req.method==HTTP_POST) { + if(req.cont_type.find(multipart_tag,cset_lcase)>=0) PushMultipart(map,req); + else PushWWWForm(map,req.body); + } + else if(req.method==HTTP_PUT) { + Const(map,body_tag,req.body,tok_t::PUBLIC); + } +} -- cgit v1.2.3