From 9344d3c324f230024af56c3ebe544a8003390160 Mon Sep 17 00:00:00 2001 From: rtabor Date: Wed, 27 Sep 2017 14:48:06 -0400 Subject: [PATCH] Added logic to skip firstLine response header if HTTP 2.0 --- charles_to_postman.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/charles_to_postman.py b/charles_to_postman.py index fcebc60..5b03b7b 100644 --- a/charles_to_postman.py +++ b/charles_to_postman.py @@ -177,10 +177,14 @@ def convert_charles_to_postman(charles_node): status_code = c_response['status'] p_response = {'name': path, 'originalRequest': p_request, 'code': status_code, 'header': [], 'cookie': []} - p_status = c_response['header']['firstLine'].replace( - '%s %d ' % (protocol, status_code), '') + try: + p_status = c_response['header']['firstLine'].replace( + '%s %d ' % (protocol, status_code), '') - p_response['status'] = p_status + p_response['status'] = p_status + except KeyError: + pass + for header in c_response['header']['headers']: p_response['header'].append( {'key': header['name'], 'value': header['value']})