Dolda2000 GitWeb
/
wrw.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into python2
[wrw.git]
/
wrw
/
form.py
diff --git
a/wrw/form.py
b/wrw/form.py
index
de40092
..
76abab6
100644
(file)
--- a/
wrw/form.py
+++ b/
wrw/form.py
@@
-7,9
+7,12
@@
def formparse(req):
buf = {}
buf.update(urlparse.parse_qsl(req.query))
if req.ihead.get("Content-Type") == "application/x-www-form-urlencoded":
buf = {}
buf.update(urlparse.parse_qsl(req.query))
if req.ihead.get("Content-Type") == "application/x-www-form-urlencoded":
- rbody = req.input(2 ** 20)
+ try:
+ rbody = req.input.read(2 ** 20)
+ except IOError as exc:
+ return exc
if len(rbody) >= 2 ** 20:
if len(rbody) >= 2 ** 20:
- r
aise
ValueError("x-www-form-urlencoded data is absurdly long")
+ r
eturn
ValueError("x-www-form-urlencoded data is absurdly long")
buf.update(urlparse.parse_qsl(rbody))
return buf
buf.update(urlparse.parse_qsl(rbody))
return buf
@@
-81,7
+84,9
@@
class formpart(object):
return ret
def close(self):
return ret
def close(self):
- self.fillbuf(-1)
+ while True:
+ if self.read(8192) == "":
+ break
def __enter__(self):
return self
def __enter__(self):
return self
@@
-152,5
+157,10
@@
class multipart(object):
self.lastpart.parsehead()
return self.lastpart
self.lastpart.parsehead()
return self.lastpart
-def formdata(req):
- return req.item(formparse)
+def formdata(req, onerror=Exception):
+ data = req.item(formparse)
+ if isinstance(data, Exception):
+ if onerror is Exception:
+ raise data
+ return onerror
+ return data