how to send 100 continues in wsgi application ?

gert gert.cuykens at gmail.com
Fri Aug 28 21:24:25 CEST 2009


how do you send 100 continues in a wsgi applications ?

when using curl -T file http://localhost/upload.wsgi on the
wsgiref.simple_server it get stuck waiting for a 100 continue

import os

def application(environ, response):
    query=os.path.join(os.path.dirname(__file__),'teeeeeeeeeemp')
    range=environ.get('HTTP_CONTENT_RANGE','bytes 0-').replace('bytes
','').split('/')[0].split(',')
    offset=[]
    for r in range: offset.append(r.split('-'))
    with open(query,'ab+') as f:
         if environ['REQUEST_METHOD']=='PUT':
             f.seek(int(offset[0][0]))
             f.truncate()
             while True:
                 chunk=environ['wsgi.input'].read(8192)
                 if not chunk: break
                 f.write(chunk)
             f.flush()
         l=str(os.fstat(f.fileno()).st_size)
    response('200 OK', [('Content-Type', 'text/plain'), ('Content-
Length', str(len(l)))])
    return [l]






More information about the Python-list mailing list