Changeset 4cebb0acbd14f94545d4dbbdb4b1727384aa355c

Show
Ignore:
Timestamp:
07/25/12 22:14:02 (2 years ago)
Author:
Theo Schlossnagle <jesus@lethargy.org>
git-committer:
Theo Schlossnagle <jesus@lethargy.org> 1343254442 -0700
git-parent:

[394f152f69d57e46eb54186650262be1ff0d9f59], [278be6a7d225b9ab718e0c0db325c1299f5b3835]

git-author:
Theo Schlossnagle <jesus@lethargy.org> 1343254442 -0700
Message:

Merge pull request #94 from pquerna/zlib_iis_errors

zlib data errors with some IIS servers

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/lua_noit.c

    r18f8b0b r278be6a  
    14401440  uLong outlen = 0; 
    14411441  int limit = 1024*1024; 
     1442  int allow_restart = 1; 
    14421443  int err, n = lua_gettop(L); 
    14431444 
     
    14651466      /* got some data */ 
    14661467      int size_read = DEFLATE_CHUNK_SIZE - stream->avail_out; 
     1468      allow_restart = 0; 
    14671469      uLong newoutlen = outlen + size_read; 
    14681470      if(limit && newoutlen > limit) { 
     
    14891491      } 
    14901492    } 
    1491     else break; 
     1493    else if(allow_restart && err == Z_DATA_ERROR) { 
     1494      /* Rarely seen, but on the internet, some IIS servers seem 
     1495       * to not generate 'correct' deflate streams, so we use 
     1496       * inflateInit2 here to manually configure the stream. 
     1497       */ 
     1498      inflateEnd(stream); 
     1499      err = inflateInit2(stream, -MAX_WBITS); 
     1500      if (err != Z_OK) { 
     1501        break; 
     1502      } 
     1503      stream->next_in = (Bytef *)input; 
     1504      stream->avail_in = inlen; 
     1505      allow_restart = 0; 
     1506      continue; 
     1507    } 
     1508    else { 
     1509      break; 
     1510    } 
     1511 
    14921512    if(stream->avail_in == 0) break; 
    14931513  }