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