{"id":16516889,"url":"https://github.com/alkasm/httpx-grpc","last_synced_at":"2025-07-01T13:06:57.366Z","repository":{"id":123352042,"uuid":"345321612","full_name":"alkasm/httpx-grpc","owner":"alkasm","description":null,"archived":false,"fork":false,"pushed_at":"2021-03-08T06:53:29.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-01T13:05:05.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alkasm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-07T10:52:51.000Z","updated_at":"2021-03-08T06:53:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"03d8d2c0-360d-48a2-9a22-7b63c47ffc48","html_url":"https://github.com/alkasm/httpx-grpc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alkasm/httpx-grpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Fhttpx-grpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Fhttpx-grpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Fhttpx-grpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Fhttpx-grpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alkasm","download_url":"https://codeload.github.com/alkasm/httpx-grpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Fhttpx-grpc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262969886,"owners_count":23392529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T16:27:27.936Z","updated_at":"2025-07-01T13:06:57.344Z","avatar_url":"https://github.com/alkasm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Attempt at using httpx as a client for gRPC calls over HTTP/2.\n\nThe `httpcore` library seems to think the connection is HTTP/1.1 and not HTTP/2 over 127.0.0.1. \n\nInstall the dependencies: `pip install -r requirements.txt` (alternatively `pip install httpx[http2] grpcio protobuf`)\n\nStart the local gRPC server on 50051: `python grpc-server.py`\n\ngRPC client (works): `python grpc-client.py`\n\u003cdetails\u003e\u003csummary\u003eoutput\u003c/summary\u003e\nHello world\n\u003c/details\u003e\n\nhttpx client (doesn't work): `python httpx-client.py`\n\u003cdetails\u003e\u003csummary\u003eoutput\u003c/summary\u003e\n\n```\n$ python httpx-client.py \nTraceback (most recent call last):\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpx/_exceptions.py\", line 326, in map_exceptions\n    yield\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpx/_client.py\", line 869, in _send_single_request\n    ext={\"timeout\": timeout.as_dict()},\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpx/_transports/default.py\", line 102, in request\n    return self._pool.request(method, url, headers=headers, stream=stream, ext=ext)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_sync/connection_pool.py\", line 219, in request\n    method, url, headers=headers, stream=stream, ext=ext\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_sync/connection.py\", line 115, in request\n    return self.connection.request(method, url, headers, stream, ext)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_sync/http11.py\", line 72, in request\n    ) = self._receive_response(timeout)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_sync/http11.py\", line 133, in _receive_response\n    event = self._receive_event(timeout)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_sync/http11.py\", line 169, in _receive_event\n    event = self.h11_state.next_event()\n  File \"/Users/alkasm/.pyenv/versions/3.7.7/lib/python3.7/contextlib.py\", line 130, in __exit__\n    self.gen.throw(type, value, traceback)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_exceptions.py\", line 12, in map_exceptions\n    raise to_exc(exc) from None\nhttpcore.RemoteProtocolError: illegal request line\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"httpx-client.py\", line 16, in \u003cmodule\u003e\n    response = client.post(route, content=serialized_request, headers=headers)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpx/_client.py\", line 1008, in post\n    timeout=timeout,\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpx/_client.py\", line 729, in request\n    request, auth=auth, allow_redirects=allow_redirects, timeout=timeout\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpx/_client.py\", line 770, in send\n    history=[],\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpx/_client.py\", line 810, in _send_handling_auth\n    history=history,\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpx/_client.py\", line 839, in _send_handling_redirects\n    response = self._send_single_request(request, timeout)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpx/_client.py\", line 869, in _send_single_request\n    ext={\"timeout\": timeout.as_dict()},\n  File \"/Users/alkasm/.pyenv/versions/3.7.7/lib/python3.7/contextlib.py\", line 130, in __exit__\n    self.gen.throw(type, value, traceback)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpx/_exceptions.py\", line 343, in map_exceptions\n    raise mapped_exc(message, **kwargs) from exc  # type: ignore\nhttpx.RemoteProtocolError: illegal request line\n```\n\u003c/details\u003e\n\nhttpcore client (doesn't work): `python httpcore-client.py`\n\u003cdetails\u003e\u003csummary\u003eoutput\u003c/summary\u003e\n\n```\n$ python httpcore-client.py \nTraceback (most recent call last):\n  File \"httpcore-client.py\", line 17, in \u003cmodule\u003e\n    headers=[(b\"host\", b\"127.0.0.1\"), *headers],\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_sync/connection_pool.py\", line 219, in request\n    method, url, headers=headers, stream=stream, ext=ext\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_sync/connection.py\", line 115, in request\n    return self.connection.request(method, url, headers, stream, ext)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_sync/http11.py\", line 72, in request\n    ) = self._receive_response(timeout)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_sync/http11.py\", line 133, in _receive_response\n    event = self._receive_event(timeout)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_sync/http11.py\", line 169, in _receive_event\n    event = self.h11_state.next_event()\n  File \"/Users/alkasm/.pyenv/versions/3.7.7/lib/python3.7/contextlib.py\", line 130, in __exit__\n    self.gen.throw(type, value, traceback)\n  File \"/Users/alkasm/prog/httpx-grpc/venv/lib/python3.7/site-packages/httpcore/_exceptions.py\", line 12, in map_exceptions\n    raise to_exc(exc) from None\nhttpcore.RemoteProtocolError: illegal request line\n```\n\u003c/details\u003e\n\nAdditionally when setting up an HTTP/2 server via hyper-h2 (`python hyper-server.py`), the same `RemoteProtocolError: illegal request line` error crops up when hitting it from httpcore or httpx, and the server raises an `h2.exceptions.ProtocolError: Invalid HTTP/2 preamble`. Httpcore is still going through an HTTP/1.1 connection in both cases, according to a little print I added in `SyncHTTPConnection.request()` (and according to the traceback):\n```\nhttp2: True\nis_http11: True\nis_http2: False\n```\n\nWhen hitting the hyper-h2 server with the gRPC client, the request is logged as expected:\n```\n\u003cRequestReceived stream_id:1, headers:[(':scheme', 'http'), (':method', 'POST'), (':authority', '127.0.0.1:50051'), (':path', '/helloworld.Greeter/SayHello'), ('te', 'trailers'), ('content-type', 'application/grpc'), ('user-agent', 'grpc-python/1.36.1 grpc-c/15.0.0 (osx; chttp2)'), ('grpc-accept-encoding', 'identity,deflate,gzip'), ('accept-encoding', 'identity,gzip')]\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkasm%2Fhttpx-grpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falkasm%2Fhttpx-grpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkasm%2Fhttpx-grpc/lists"}