Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions httpcore/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
from urllib.parse import parse_qsl, urlencode

import chardet
import idna
import rfc3986

from .config import SSLConfig, TimeoutConfig
from .decoders import (
ACCEPT_ENCODING,
SUPPORTED_DECODERS,
Expand Down Expand Up @@ -808,15 +806,15 @@ def stream(self) -> typing.Iterator[bytes]:
while True:
try:
yield self._loop.run_until_complete(inner.__anext__())
except StopAsyncIteration as exc:
except StopAsyncIteration:
break

def raw(self) -> typing.Iterator[bytes]:
inner = self._response.raw()
while True:
try:
yield self._loop.run_until_complete(inner.__anext__())
except StopAsyncIteration as exc:
except StopAsyncIteration:
break

def close(self) -> None:
Expand Down
6 changes: 4 additions & 2 deletions tests/models/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ async def streaming_body(data):


def test_url():
request = httpcore.Request("GET", "http://example.org")
url = "http://example.org"
request = httpcore.Request("GET", url)
assert request.url.scheme == "http"
assert request.url.port == 80
assert request.url.full_path == "/"

request = httpcore.Request("GET", "https://example.org/abc?foo=bar")
url = "https://example.org/abc?foo=bar"
request = httpcore.Request("GET", url)
assert request.url.scheme == "https"
assert request.url.port == 443
assert request.url.full_path == "/abc?foo=bar"
Expand Down
11 changes: 11 additions & 0 deletions tests/models/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,14 @@ def test_url_query_params():
"https://example.org:123/path/to/somewhere?b=456", query_params={"a": "123"}
)
assert str(url) == "https://example.org:123/path/to/somewhere?a=123"


def test_url_set():
urls = (
URL("http://example.org:123/path/to/somewhere"),
URL("http://example.org:123/path/to/somewhere/else"),
)

url_set = set(urls)

assert all(url in urls for url in url_set)