Fix: Preseve status code in header when != 200

before:
    reply: 'HTTP/1.1 400 Bad Request\n'
    header: date: Wed, 16 Apr 2014 00:30:07 GMT
    header: content-type: text/plain; charset=utf-8
    header: content-length: 286
    header: server: Python/HTTPretty
    header: status: 200
    header: connection: close

after:
    reply: 'HTTP/1.1 400 Bad Request\n'
    header: date: Wed, 16 Apr 2014 00:32:45 GMT
    header: content-type: text/plain; charset=utf-8
    header: content-length: 286
    header: server: Python/HTTPretty
    header: status: 400
    header: connection: close

Note how status and reply http did not match before but do now.
This commit is contained in:
Ilya Sukhanov 2014-04-15 20:46:17 -04:00
parent aa644b4340
commit e76b4c1250

View File

@ -58,7 +58,7 @@ class BaseResponse(object):
return 200, headers, response
else:
body, new_headers = response
status = new_headers.pop('status', 200)
status = new_headers.get('status', 200)
headers.update(new_headers)
return status, headers, body
raise NotImplementedError("The {0} action has not been implemented".format(action))