From d60a2c9297c35b3286c0c9218cccacd2f06c76e9 Mon Sep 17 00:00:00 2001 From: kgriffs Date: Fri, 31 Jan 2014 15:35:34 -0600 Subject: [PATCH] fix(falcon.testing): create_environ does not support None header values This patch makes it so that you can pass in a headers dict with individual headers that contain None, and those will translate to the empty string. --- falcon/testing/helpers.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/falcon/testing/helpers.py b/falcon/testing/helpers.py index 4e028e6..03fcfb5 100644 --- a/falcon/testing/helpers.py +++ b/falcon/testing/helpers.py @@ -132,9 +132,14 @@ def _add_headers_to_environ(env, headers): for name, value in headers.items(): name = name.upper().replace('-', '_') - if name == 'CONTENT_TYPE': - env[name] = value.strip() - elif name == 'CONTENT_LENGTH': - env[name] = value.strip() + if value is None: + value = '' else: - env['HTTP_' + name.upper()] = value.strip() + value = value.strip() + + if name == 'CONTENT_TYPE': + env[name] = value + elif name == 'CONTENT_LENGTH': + env[name] = value + else: + env['HTTP_' + name.upper()] = value