Skip to content

Доп. задача#1

Open
iffomko wants to merge 9 commits intomainfrom
develop
Open

Доп. задача#1
iffomko wants to merge 9 commits intomainfrom
develop

Conversation

@iffomko
Copy link
Copy Markdown
Collaborator

@iffomko iffomko commented May 12, 2023

No description provided.

iffomko added 3 commits May 12, 2023 18:11
… данных на клиенте. Если это был GET запрос, то в ответе присылается код ответа и количество вхождений под строчки в строку с результатом от сервера. В остальных случаях просто возвращает ответ от сервера. Также для клиента добавил формочку, которая запрашивает эту строчку, если выбрана кнопка GET запроса
server/server.py Outdated
if not HttpServer.validate_body(settings):
response = HttpServer.create_bad_request_response(
origin,
'Вы не ввели либо url, либо тип запроса'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а давай писать чего именно недостает - а то чот ка кто непонятненько

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переделал. Теперь возвращаются понятные сообщения от валидации

server/server.py Outdated
client_data = client.get_data()

client_data = client.get_data()
if client_data == 'Неправильный url адрес или port':
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мммммммммм, хардкод строк, вкусно

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавил все в енамы

server/server.py Outdated

response = self.create_response(client_data, origin)
conn.sendall(response.encode())
if settings.get('request').lower() == 'get' and len(settings.get('get_form')) != 0:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

уверен, что именно так надо сравнивать?)))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вынес все в енамы

server/server.py Outdated
Comment on lines +102 to +107
if \
body.get('url') is None or \
body.get('request') is None or \
type(body.get('cookie')) != dict or \
type(body.get('headers')) != dict or \
type(body.get('body')) != str:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а давай условие в скобки занесем, и не будем такие переносы делать?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделал несколько отдельных if для этого

server/server.py Outdated
if \
body.get('url') is None or \
body.get('request') is None or \
type(body.get('cookie')) != dict or \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а еще типы сравнивают как isinstance а не чеканьем типов от type)))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поменял на isinstance

server/server.py Outdated
"""

if \
body.get('url') is None or \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body.get('url') is None or \
not body.get('url') or

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants