Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mtford90 committed Jul 4, 2014
1 parent c14b50f commit 14d247c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ requests>=2,<=3,
sqlparse>=0.1,<0.2,
Jinja2>=2.7,<3,
autopep8>=1,<2
rawes>=5,<6
pytz==2014.2
pyeqs>=0.8.1,<1
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
'sqlparse>=0.1,<0.2',
'Jinja2>=2.7,<3',
'autopep8>=1,<2',
'pytz==2014.2'
'rawes>=5,<6',
'pytz==2014.2',
'pyeqs>=0.8.1<1'
]
)
11 changes: 9 additions & 2 deletions silk/model_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def body(self):
raw_body = raw_body.decode('UTF-8')
except AttributeError:
pass
except UnicodeDecodeError:
raw_body = ''
except Exception as e:
Logger.error('Unable to decode request body using char_set %s due to error: %s. Will ignore. Stacktrace:' % (char_set, e))
traceback.print_exc()
Expand All @@ -112,6 +114,8 @@ def body(self):
raw_body = raw_body.decode('UTF-8')
except AttributeError:
pass
except UnicodeDecodeError:
raw_body = ''
max_size = SilkyConfig().SILKY_MAX_REQUEST_BODY_SIZE
body = ''
if raw_body:
Expand Down Expand Up @@ -188,6 +192,8 @@ def body(self):
content = content.decode('UTF-8')
except AttributeError:
pass
except UnicodeDecodeError:
content = ''
except Exception as e:
Logger.error('Unable to decode response body using char_set %s due to error: %s. Will ignore. Stacktrace:' % (char_set, e))
traceback.print_exc()
Expand All @@ -197,6 +203,8 @@ def body(self):
content = content.decode('UTF-8')
except AttributeError:
pass
except UnicodeDecodeError:
content = ''
if content:
max_body_size = SilkyConfig().SILKY_MAX_RESPONSE_BODY_SIZE
if max_body_size > -1:
Expand All @@ -220,7 +228,6 @@ def body(self):
return body, content

def construct_response_model(self):

assert self.request, 'Cant construct a response model if there is no request model'
Logger.debug('Creating response model for request model with pk %s' % self.request.pk)
b, content = self.body()
Expand All @@ -243,4 +250,4 @@ def construct_response_model(self):
silky_response.raw_body = content
except UnicodeDecodeError:
Logger.debug('NYI: Saving of binary response body') # TODO
return silky_response
return silky_response

0 comments on commit 14d247c

Please sign in to comment.