req = Request.blank('/test?check=a&check=b&name=Bob')
req.method = 'PUT'
req.body = body = 'var1=value1&var2=value2&rep=1&rep=2'
req.environ['CONTENT_LENGTH'] = str(len(req.body))
req.environ['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
req.GET
# Why post have items???
req.POST

req.charset = 'utf8'

req = Request.blank('/')
def wsgi_app(environ, start_response):
    start_response('200 OK', [('Content-type', 'text/plain')])
    return ['Hi!']
req.call_application(wsgi_app)
res = req.get_response(wsgi_app)

# add user defined attribute
req.some_attr = 'blah blah blah'
new_req = Request(req.environ)
new_req.some_attr
req.environ['webob.adhoc_attrs']

# response
res = Response()
res.status
res.headerlist
res.body
res.status = 404
res.status
예제 #2
0
req.environ['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
req.GET
# Why post have items???
req.POST

req.charset = 'utf8'

req = Request.blank('/')


def wsgi_app(environ, start_response):
    start_response('200 OK', [('Content-type', 'text/plain')])
    return ['Hi!']


req.call_application(wsgi_app)
res = req.get_response(wsgi_app)

# add user defined attribute
req.some_attr = 'blah blah blah'
new_req = Request(req.environ)
new_req.some_attr
req.environ['webob.adhoc_attrs']

# response
res = Response()
res.status
res.headerlist
res.body
res.status = 404
res.status