aio-libs / aio-libs/aiohttp

Response not passed to WSServerHandshakeError

Đang mở
#2,279 9 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement need pull request
Ngôn ngữ chính
Python
Star
16.5k
Fork
2.4k
Merge trung bình
17 giờ 22 phút
Pull request đã merge (30 ngày)
212

Mô tả

## Long story short

As requested in [comment on issue 701](https://github.com/aio-libs/aiohttp/issues/701#issuecomment-330762574) opening a new issue

WSServerHandshakeError does not provide the actual HTTP Response body.
This means any error handling code, logging code cannot provide the error information that the server provides in the response body with the normal Client object.

In order to work around this issue we use a client like this to get access to the response:
```python
class LoggingClientSession(aiohttp.ClientSession):
@asyncio.coroutine
def _request(self, method, url, **kwargs):
self.last_response = yield from super()._request(method, url, **kwargs)
return self.last_response
```

## Expected behaviour

Provide the complete response object as a property in the error. This way any change to the interface of the standard response is propagated directly without additional code changes.

## Actual behaviour

WSServerHandshakeError only forwards a subset of the response. See this code: https://github.com/aio-libs/aiohttp/blob/master/aiohttp/client.py#L434

## Steps to reproduce

Connect to a websocket server that responds to an upgrade request with an error response with body.

## Your environment
not relevant.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.