this downloads itself without chunked
r...@localhost:/usr/httpd/www/appwsgi/wsgi# curl
http://192.168.2.17/appwsgi/wsgi/download2.wsgi?download2.wsgi
import os,sys
class FileWrapper(object):
def __init__(self, fp, blksize=8192):
self.fp = fp
self.blksize=blksize
def __getitem__(self, key):
data = self.fp.read(self.blksize)
if data: return data
raise IndexError
def close(self):
self.fp.close()
def application(environ, response):
query=environ['QUERY_STRING']
print (query, file=sys.stderr)
query=os.path.join(os.path.dirname(__file__),query)
range=environ.get('HTTP_RANGE','bytes=0-').replace
('bytes=','').split(',')
offset=[]
for r in range: offset.append(r.split('-'))
f=open(query, 'rb')
f.seek(int(offset[0][0]))
lengthF=os.fstat(f.fileno()).st_size
lengthC=str(lengthF-int(offset[0][0]))
bitS=int(offset[0][0])
bitE=lengthF-1
bytes='bytes '+str(bitS)+'-'+str(bitE)+'/'+str(lengthF)
#response('200 OK', [('Content-Type', 'image/png'), ('Content-
Length', lengthC), ('Content-Range', bytes), ])
response('200 OK', [('Content-Type', 'image/png'), ('Content-
Length', lengthC), ('Content-Range', bytes)])
if 'wsgi.file_wrapper' in environ: return environ
['wsgi.file_wrapper'](f, 8192)
else: return FileWrapper(f, 8192)
this downloads itself with chunked ?
r...@localhost:/usr/httpd/www/appwsgi/wsgi# curl
http://192.168.2.17/appwsgi/wsgi/download2.wsgi?download2.wsgi -v
* About to connect() to 192.168.2.17 port 80 (#0)
* Trying 192.168.2.17... connected
* Connected to 192.168.2.17 (192.168.2.17) port 80 (#0)
> GET /appwsgi/wsgi/download2.wsgi?download2.wsgi HTTP/1.1
> User-Agent: curl/7.19.5 (x86_64-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g
> zlib/1.2.3.3 libidn/1.15
> Host: 192.168.2.17
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Sat, 15 Aug 2009 21:57:50 GMT
< Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8g mod_wsgi/
3.0c5-TRUNK Python/3.1
< Content-Length: 1273
< Content-Range: bytes 0-1272/1273
< Transfer-Encoding: chunked
< Content-Type: image/png
< X-Pad: avoid browser bug
<
* Received problem 2 in the chunky parser
* Closing connection #0
curl: (56) Received problem 2 in the chunky parser
r...@localhost:/usr/httpd/www/appwsgi/wsgi#
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---