@@ -12,11 +12,13 @@ class Response:
|
||||
self.code = 200
|
||||
self.phrase = 'Success'
|
||||
self.version = 'HTTP/1.1'
|
||||
self.headers = {}
|
||||
self.content_type = "text/plain"
|
||||
self.headers = {
|
||||
'Content-Type': 'text/plain'
|
||||
}
|
||||
self.__content_type = 'text/plain'
|
||||
for key in kwargs:
|
||||
if key in self.__dict__:
|
||||
setattr(self, key, kwargs[key])
|
||||
if key in ['content_type', 'mimetype']:
|
||||
self.__content_type = kwargs[key]
|
||||
|
||||
def __call__(self):
|
||||
status = ' '.join([self.version, str(self.code), self.phrase])
|
||||
@@ -27,7 +29,6 @@ class Response:
|
||||
])
|
||||
return raw
|
||||
|
||||
def __iter__(self):
|
||||
pass
|
||||
def __next__(self):
|
||||
pass
|
||||
@property
|
||||
def content_type(self):
|
||||
return self.__content_type
|
||||
|
||||
@@ -51,6 +51,7 @@ def str_next(instance):
|
||||
if instance.position == 'headers':
|
||||
instance.position = 'body'
|
||||
raw = b''
|
||||
response.headers['Content-Type'] = response.content_type
|
||||
for key in response.headers:
|
||||
value = response.headers[key]
|
||||
raw += key.encode() + b' ' + value.encode() + crlf
|
||||
|
||||
Reference in New Issue
Block a user