Project

General

Profile

1
# HTTP
2

    
3
import httplib
4

    
5
import exc
6

    
7
class ConnectionDroppedError(exc.ExceptionWithCause): pass
8

    
9
##### httplib modifications
10

    
11
__HTTPResponse_read_orig = httplib.HTTPResponse.read
12
def __HTTPResponse_read(*args, **kw_args):
13
    try: return __HTTPResponse_read_orig(*args, **kw_args)
14
    # If the connection is dropped mid-chunk in chunked transfer encoding, raise
15
    # a ConnectionDroppedError to clarify why the IncompleteRead occurred
16
    except httplib.IncompleteRead, e: raise ConnectionDroppedError(e)
17
httplib.HTTPResponse.read = __HTTPResponse_read
(14-14/35)