@@ -70,13 +70,21 @@ def route_func(request):
7070 status : HTTPStatus
7171 headers : HTTPHeaders
7272 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+ """
7381
7482 def __init__ ( # pylint: disable=too-many-arguments
7583 self ,
7684 request : HTTPRequest ,
7785 status : Union [HTTPStatus , Tuple [int , str ]] = CommonHTTPStatus .OK_200 ,
7886 headers : Union [HTTPHeaders , Dict [str , str ]] = None ,
79- content_type : str = MIMEType . TYPE_TXT ,
87+ content_type : str = None ,
8088 http_version : str = "HTTP/1.1" ,
8189 chunked : bool = False ,
8290 ) -> None :
@@ -103,7 +111,7 @@ def __init__( # pylint: disable=too-many-arguments
103111 def _send_headers (
104112 self ,
105113 content_length : Optional [int ] = None ,
106- content_type : str = MIMEType . TYPE_TXT ,
114+ content_type : str = None ,
107115 ) -> None :
108116 """
109117 Sends headers.
@@ -116,7 +124,9 @@ def _send_headers(
116124 f"{ self .http_version } { self .status .code } { self .status .text } \r \n "
117125 )
118126
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+ )
120130 headers .setdefault ("Connection" , "close" )
121131 if self .chunked :
122132 headers .setdefault ("Transfer-Encoding" , "chunked" )
0 commit comments