Skip to content

Commit

Permalink
Version 0.8.1 (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie authored Apr 30, 2020
1 parent 6051919 commit ea63f14
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## 0.8.1 (April 30th, 2020)

### Changed

- Allow inherintance of both `httpcore.AsyncByteStream`, `httpcore.SyncByteStream` without type conflicts.

## 0.8.0 (April 30th, 2020)

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion httpcore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"WriteError",
"CloseError",
]
__version__ = "0.8.0"
__version__ = "0.8.1"
12 changes: 6 additions & 6 deletions httpcore/_async/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ class AsyncByteStream:
"""

def __init__(
self, iterator: AsyncIterator[bytes] = None, close_func: Callable = None,
self, aiterator: AsyncIterator[bytes] = None, aclose_func: Callable = None,
) -> None:
self.iterator = empty() if iterator is None else iterator
self.close_func = close_func
self.aiterator = empty() if aiterator is None else aiterator
self.aclose_func = aclose_func

async def __aiter__(self) -> AsyncIterator[bytes]:
"""
Yield bytes representing the request or response body.
"""
async for chunk in self.iterator:
async for chunk in self.aiterator:
yield chunk

async def aclose(self) -> None:
"""
Must be called by the client to indicate that the stream has been closed.
"""
if self.close_func is not None:
await self.close_func()
if self.aclose_func is not None:
await self.aclose_func()


class AsyncHTTPTransport:
Expand Down
4 changes: 2 additions & 2 deletions httpcore/_async/http11.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ async def request(
headers,
) = await self._receive_response(timeout)
stream = AsyncByteStream(
iterator=self._receive_response_data(timeout),
close_func=self._response_closed,
aiterator=self._receive_response_data(timeout),
aclose_func=self._response_closed,
)
return (http_version, status_code, reason_phrase, headers, stream)

Expand Down
2 changes: 1 addition & 1 deletion httpcore/_async/http2.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ async def request(
status_code, headers = await self.receive_response(timeout)
reason_phrase = get_reason_phrase(status_code)
stream = AsyncByteStream(
iterator=self.body_iter(timeout), close_func=self._response_closed
aiterator=self.body_iter(timeout), aclose_func=self._response_closed
)

return (b"HTTP/2", status_code, reason_phrase, headers, stream)
Expand Down
2 changes: 2 additions & 0 deletions unasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
('async for', 'for'),
('await ', ''),
('aclose', 'close'),
('aclose_func', 'close_func'),
('aiterator', 'iterator'),
('__aenter__', '__enter__'),
('__aexit__', '__exit__'),
('__aiter__', '__iter__'),
Expand Down

0 comments on commit ea63f14

Please sign in to comment.