My favorites | Sign in
Project Home Downloads Wiki
New issue   Search
  Advanced search   Search tips   Subscriptions
Issue 100: Result truncated when using wsgi.file_wrapper.
2 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Closed:  Aug 2008

Sign in to add a comment
Project Member Reported by, Aug 21, 2008
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')

    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:

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.

Aug 23, 2008
Project Member #1
Version 2.2 released which fixes this.
Status: Fixed
Sign in to add a comment

Powered by Google Project Hosting