Skip to content

Commit f3f15e6

Browse files
committed
# 0.1.1
* Response: added `original` proxy property
1 parent 2c6c30e commit f3f15e6

7 files changed

Lines changed: 16 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 0.1.1
2+
* Response: added `original` proxy property
3+
14
# 0.1.0
25

36
* Initial release

examples/demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ async def demo2():
6666
"https://ifconfig.co/json" # , path_template="/json"
6767
) as response:
6868
print(await response.read())
69-
print(response.backend_response.original().headers)
70-
# assert response.backend_response.original().http_version == "HTTP/2"
69+
print(response.original.headers)
70+
# assert response.original.http_version == "HTTP/2"
7171

7272

7373
asyncio.run(demo2())

extapi/http/types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ class Response(Generic[T]):
6767

6868
_data: bytes | None = None
6969

70+
@property
71+
def original(self) -> T:
72+
return self.backend_response.original()
73+
7074
async def read(self) -> bytes:
7175
if self._data is not None:
7276
return self._data

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "extapi"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
description = "External API library"
55
authors = [
66
{ name = "KTS", email = "hello@kts.tech" }

tests/exthttp/backends/test_aiohttp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def test_execute(self, dummy_server: TestServer):
2525
response = await executor.execute(request)
2626
assert response.status == 200
2727
assert response.url == request.url
28-
assert response.backend_response.original().status == 200
28+
assert response.original.status == 200
2929

3030
async def test_execute_unknown(self, dummy_server: TestServer):
3131
async with AiohttpExecutor() as executor:
@@ -37,7 +37,7 @@ async def test_execute_unknown(self, dummy_server: TestServer):
3737
response = await executor.execute(request)
3838
assert response.status == 404
3939
assert response.url == request.url
40-
assert response.backend_response.original().status == 404
40+
assert response.original.status == 404
4141

4242
async def test_read(self, dummy_server: TestServer):
4343
async with AiohttpExecutor() as executor:

tests/exthttp/backends/test_httpx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def test_execute(self, dummy_server: TestServer):
2424
response = await executor.execute(request)
2525
assert response.status == 200
2626
assert response.url == request.url
27-
assert response.backend_response.original().status_code == 200
27+
assert response.original.status_code == 200
2828

2929
async def test_execute_unknown(self, dummy_server: TestServer):
3030
async with HttpxExecutor() as executor:
@@ -36,7 +36,7 @@ async def test_execute_unknown(self, dummy_server: TestServer):
3636
response = await executor.execute(request)
3737
assert response.status == 404
3838
assert response.url == request.url
39-
assert response.backend_response.original().status_code == 404
39+
assert response.original.status_code == 404
4040

4141
async def test_read(self, dummy_server: TestServer):
4242
async with HttpxExecutor() as executor:

tests/exthttp/test_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ async def read(self) -> bytes:
8787
async with response as resp:
8888
assert resp is response
8989
assert isinstance(resp.backend_response, _Resp)
90+
assert resp.original == b""
9091

9192
assert called is True
9293

@@ -114,5 +115,6 @@ async def json(self, **kwargs) -> Any:
114115
async with response as resp:
115116
assert resp is response
116117
assert isinstance(resp.backend_response, _Resp)
118+
assert resp.original == b""
117119

118120
assert called is True

0 commit comments

Comments
 (0)