From 7197d800be098b0f32607b8d95869d1347a5f097 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 15 Feb 2018 10:54:43 +0000 Subject: [PATCH] Don't mutate request.headers with --debug. --- coreapi_cli/__init__.py | 2 +- coreapi_cli/debug.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/coreapi_cli/__init__.py b/coreapi_cli/__init__.py index 9e604c0..e13bd59 100644 --- a/coreapi_cli/__init__.py +++ b/coreapi_cli/__init__.py @@ -1 +1 @@ -__version__ = "1.0.7" +__version__ = "1.0.8" diff --git a/coreapi_cli/debug.py b/coreapi_cli/debug.py index 8c92ff5..499c870 100644 --- a/coreapi_cli/debug.py +++ b/coreapi_cli/debug.py @@ -14,12 +14,14 @@ def debug_request(request): def request_echo(fmt, *args): click.echo(click.style('> ', fg='blue') + expand_args(fmt, args)) - headers = request.headers - headers['host'] = urlparse.urlparse(request.url).hostname - request_echo(click.style('%s %s HTTP/1.1', bold=True), request.method, request.path_url) - for key, value in sorted(headers.items()): + + if 'host' not in request.headers: + request_echo('Host: %s', urlparse.urlparse(request.url).netloc) + + for key, value in sorted(request.headers.items()): request_echo('%s: %s', key.title(), value) + if request.body: body_text = request.body if isinstance(body_text, bytes):