@@ -15,7 +15,7 @@ from nucleus.handlers.terminator import (
|
|||||||
handler_interrupt,
|
handler_interrupt,
|
||||||
handler_terminate
|
handler_terminate
|
||||||
)
|
)
|
||||||
from nucleus.domains.http.models.response import Response
|
from nucleus.response.common import Response
|
||||||
|
|
||||||
|
|
||||||
log = getLogger(__name__)
|
log = getLogger(__name__)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from dsl.injector.dsl import register
|
|||||||
from dsl.handlers.state import variable_addition, variable_get
|
from dsl.handlers.state import variable_addition, variable_get
|
||||||
from helpers.yaml import yaml_read
|
from helpers.yaml import yaml_read
|
||||||
|
|
||||||
from nucleus.domains.http.models.response import Response
|
from nucleus.response.common import Response
|
||||||
from nucleus.core import config
|
from nucleus.core import config
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
__author__ = 'RemiZOffAlex'
|
|
||||||
__email__ = 'remizoffalex@mail.ru'
|
|
||||||
|
|
||||||
|
|
||||||
class Response:
|
|
||||||
def __init__(self, data, **kwargs):
|
|
||||||
self.code = 200
|
|
||||||
self.phrase = 'Success'
|
|
||||||
self.version = 'HTTP/1.1'
|
|
||||||
self.headers = {}
|
|
||||||
self.content_type = "text/plain"
|
|
||||||
self.__data = data
|
|
||||||
for key in kwargs:
|
|
||||||
if key in self.__dict__:
|
|
||||||
setattr(self, key, kwargs[key])
|
|
||||||
|
|
||||||
def __call__(self):
|
|
||||||
status = ' '.join([self.version, str(self.code), self.phrase])
|
|
||||||
crlf = b'\r\n'*2
|
|
||||||
raw = crlf.join([
|
|
||||||
status.encode(),
|
|
||||||
self.__data.encode()
|
|
||||||
])
|
|
||||||
return raw
|
|
||||||
|
|
||||||
def __getitem__(self, index):
|
|
||||||
pass
|
|
||||||
def __iter__(self):
|
|
||||||
pass
|
|
||||||
def __next__(self):
|
|
||||||
pass
|
|
||||||
@@ -3,10 +3,12 @@ __email__ = 'remizoffalex@mail.ru'
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from nucleus.domains.http.models.response import Response
|
from nucleus.response.common import Response
|
||||||
|
from nucleus.response.stream import ResponseStream
|
||||||
|
|
||||||
|
|
||||||
class TestResponse(unittest.TestCase):
|
class TestResponse(unittest.TestCase):
|
||||||
def test_response(self):
|
def test_response(self):
|
||||||
response = Response('ok')
|
response = Response('ok')
|
||||||
print(response())
|
for item in ResponseStream(response):
|
||||||
|
print(item)
|
||||||
|
|||||||
Reference in New Issue
Block a user