@@ -70,13 +70,21 @@ def route_func(request):
70
70
status : HTTPStatus
71
71
headers : HTTPHeaders
72
72
content_type : str
73
+ """
74
+ Defaults to ``text/plain`` if not set.
75
+
76
+ Can be explicitly provided in the constructor, in `send()` or
77
+ implicitly determined from filename in `send_file()`.
78
+
79
+ Common MIME types are defined in `adafruit_httpserver.mime_type.MIMEType`.
80
+ """
73
81
74
82
def __init__ ( # pylint: disable=too-many-arguments
75
83
self ,
76
84
request : HTTPRequest ,
77
85
status : Union [HTTPStatus , Tuple [int , str ]] = CommonHTTPStatus .OK_200 ,
78
86
headers : Union [HTTPHeaders , Dict [str , str ]] = None ,
79
- content_type : str = MIMEType . TYPE_TXT ,
87
+ content_type : str = None ,
80
88
http_version : str = "HTTP/1.1" ,
81
89
chunked : bool = False ,
82
90
) -> None :
@@ -103,7 +111,7 @@ def __init__( # pylint: disable=too-many-arguments
103
111
def _send_headers (
104
112
self ,
105
113
content_length : Optional [int ] = None ,
106
- content_type : str = MIMEType . TYPE_TXT ,
114
+ content_type : str = None ,
107
115
) -> None :
108
116
"""
109
117
Sends headers.
@@ -116,7 +124,9 @@ def _send_headers(
116
124
f"{ self .http_version } { self .status .code } { self .status .text } \r \n "
117
125
)
118
126
119
- headers .setdefault ("Content-Type" , content_type or self .content_type )
127
+ headers .setdefault (
128
+ "Content-Type" , content_type or self .content_type or MIMEType .TYPE_TXT
129
+ )
120
130
headers .setdefault ("Connection" , "close" )
121
131
if self .chunked :
122
132
headers .setdefault ("Transfer-Encoding" , "chunked" )
0 commit comments