How to use the httpcore.SyncClient function in httpcore

To help you get started, we’ve selected a few httpcore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github encode / httpx / tests / test_sync.py View on Github external
def test_post(server):
    with httpcore.SyncClient() as http:
        response = http.post("http://127.0.0.1:8000/", data=b"Hello, world!")
    assert response.status_code == 200
    assert response.reason_phrase == "OK"
github encode / httpx / tests / test_sync.py View on Github external
def test_get(server):
    with httpcore.SyncClient() as http:
        response = http.get("http://127.0.0.1:8000/")
    assert response.status_code == 200
    assert response.content == b"Hello, world!"
    assert response.text == "Hello, world!"
github encode / httpx / tests / test_sync.py View on Github external
def test_stream_response(server):
    with httpcore.SyncClient() as http:
        response = http.get("http://127.0.0.1:8000/", stream=True)
    assert response.status_code == 200
    content = response.read()
    assert content == b"Hello, world!"
github encode / httpx / tests / test_sync.py View on Github external
def test_stream_iterator(server):
    with httpcore.SyncClient() as http:
        response = http.get("http://127.0.0.1:8000/", stream=True)
    assert response.status_code == 200
    body = b""
    for chunk in response.stream():
        body += chunk
    assert body == b"Hello, world!"
github encode / httpx / tests / test_sync.py View on Github external
def test_raw_iterator(server):
    with httpcore.SyncClient() as http:
        response = http.get("http://127.0.0.1:8000/", stream=True)
    assert response.status_code == 200
    body = b""
    for chunk in response.raw():
        body += chunk
    assert body == b"Hello, world!"