Q: Parsing http response with 2 status codes I want to parse http response and get all the status codes.
Command used
 curl -i -X PUT -T test1.txt http://sandbox.hortonworks.com:50075/webhdfs/v1/user/test.txt?op=CREATE&namenoderpcaddress=sandbox.hortonworks.com:8020&overwrite=false?op=CREATE

Below is the response I'm trying to parse
HTTP/1.1 100 Continue

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8
Content-Length: 173
Connection: close

Here is the code I'm using
rom httplib import HTTPResponse
from StringIO import StringIO

http_response_str = """HTTP/1.1 100 Continue

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8
Content-Length: 173
Connection: close"""

class FakeSocket():
    def __init__(self, response_str):
        self._file = StringIO(response_str)
    def makefile(self, *args, **kwargs):
        return self._file

source = FakeSocket(http_response_str)
response = HTTPResponse(source)
response.begin()
print "status:", response.status
print "single header:", response.getheader('Content-Type')
print "content:", response.read(len(http_response_str))

This code gives me status code as : 101 but I need both the status codes in the response.
Can someone please suggest ?
