ramkrishanbhatt / modwsgi

Automatically exported from code.google.com/p/modwsgi
0 stars 0 forks source link

Result truncated when using wsgi.file_wrapper. #100

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When using mod_wsgi 2.0/2.1 and an actual file object is supplied to 
wsgi.file_wrapper on 
Windows or if using Apache 1.3 on UNIX, if the first character of a subsequent 
block in the file is 
a NULL character, result would be truncated at that point. The default block 
size is 8192, but can 
be overridden as extra argument to wsgi.file_wrapper.

For example, following code would trigger problem:

    path = os.path.join('/tmp/null.txt')
    fd = open(path, 'w')
    fd.write(8192*'\0')
    fd.close()

    return environ['wsgi.file_wrapper'](open('/tmp/null.txt', 'rb'), 1024)

Only first 1024 characters would be returned in response.

Problem could also arise for a non file object on any platform or version of 
Apache. For example:

    import StringIO
    data = StringIO.StringIO(8192*'\0')
    return environ['wsgi.file_wrapper'](data, 1024)

Problem raise in thread:

  http://groups.google.com/group/modwsgi/browse_frm/thread/90d169459a651120?hl=en

Initial reporter didn't follow through with enough information to track it 
done, but subsequent 
person worked out trigger scenario.

As Trac is one of the few applications making use of wsgi.file_wrapper, only 
reports were 
affecting that application.

Original issue reported on code.google.com by Graham.Dumpleton@gmail.com on 22 Aug 2008 at 3:28

GoogleCodeExporter commented 8 years ago
Version 2.2 released which fixes this.

Original comment by Graham.Dumpleton@gmail.com on 24 Aug 2008 at 5:56