Open
Conversation
smartiqa
commented
Jun 2, 2019
| result = self.get_request(url, params, headers) | ||
| elif method is 'POST': | ||
| result = self.post_request(url, data, headers) | ||
| elif method is 'PUT': |
Contributor
Author
There was a problem hiding this comment.
Добавлена развилка для PUT и DELETE запросов. Для каждого варианта необходимо вызвать соответствующую функцию. Например, для PUT должна быть вызвана функция self.put_request(url, data, headers). На данный момент в POST, PUT и DELETE запросах почему-то всегда вызывается одна и та же функция self.post_request(url, data, headers).
|
|
||
| def post_request(self, url, data, headers): | ||
| return requests.post(url, data=data, headers=headers) | ||
|
|
Contributor
Author
There was a problem hiding this comment.
Как следствие из предыдущего коммента - зачем-то созданы 3(!) функции с одинаковым именем.
| http.send_request('GET', '/get') | ||
| http.send_request('POST', '/post', data={'test_key': 'test_value'}) | ||
| print(f'HTTP requests to {http.base_url} are successful!') No newline at end of file | ||
| print(f'HTTP requests to {http.base_url} are successful!') |
Contributor
Author
There was a problem hiding this comment.
Поехала табуляция. В Python необходимо уделять особое внимание отступам, так как в данном языке они являются частью синтаксиса.
| http = Http('httpbin.org', 'https') | ||
| print(f'Sending HTTP requests to {http.base_url}...') | ||
| http.send_request('GET', '/get') | ||
| http.send_request('POST', '/post', data={'test_key': 'test_value'}) |
Contributor
Author
There was a problem hiding this comment.
Отсутствуют вызовы PUT и DELETE запросов.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.