Skip to content

Commit

Permalink
Downcase all content-types
Browse files Browse the repository at this point in the history
  • Loading branch information
albertyw committed Jan 13, 2023
1 parent bb4df5b commit 4c4a1c8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion project/tests/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from silk.model_factory import ResponseModelFactory

DJANGO_META_CONTENT_TYPE = 'CONTENT_TYPE'
HTTP_CONTENT_TYPE = 'Content-Type'
HTTP_CONTENT_TYPE = 'content-type'


class TestByteStringCompatForResponse(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion project/tests/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from silk.model_factory import RequestModelFactory, ResponseModelFactory

HTTP_CONTENT_TYPE = 'Content-Type'
HTTP_CONTENT_TYPE = 'content-type'


class TestEncodingForRequests(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion project/tests/test_sensitive_data_in_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from silk.config import SilkyConfig
from silk.model_factory import RequestModelFactory

HTTP_CONTENT_TYPE = 'Content-Type'
HTTP_CONTENT_TYPE = 'content-type'
CLEANSED = RequestModelFactory.CLEANSED_SUBSTITUTE
DEFAULT_SENSITIVE_KEYS = {'username', 'api', 'token', 'key', 'secret', 'password', 'signature'}

Expand Down
2 changes: 1 addition & 1 deletion silk/code_generation/curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

curl_template = """
curl {% if method %}-X {{ method }}{% endif %}
{% if content_type %}-H 'Content-Type: {{ content_type }}'{% endif %}
{% if content_type %}-H 'content-type: {{ content_type }}'{% endif %}
{% if modifier %}{{ modifier }} {% endif %}{% if body %}'{{ body }}'{% endif %}
{{ url }}{% if query_params %}{{ query_params }}{% endif %}
{% if extra %}{{ extra }}{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions silk/model_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def default(self, o):


def _parse_content_type(content_type):
"""best efforts on pulling out the content type and encoding from Content-Type header"""
"""best efforts on pulling out the content type and encoding from content-type header"""
char_set = None
if content_type.strip():
splt = content_type.split(';')
Expand Down Expand Up @@ -267,7 +267,7 @@ def __init__(self, response):

def body(self):
body = ''
content_type, char_set = _parse_content_type(self.response.get('Content-Type', ''))
content_type, char_set = _parse_content_type(self.response.get('content-type', ''))
content = getattr(self.response, 'content', '')
if content:
max_body_size = SilkyConfig().SILKY_MAX_RESPONSE_BODY_SIZE
Expand Down

0 comments on commit 4c4a1c8

Please sign in to comment.