Skip to content
Open
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
3 changes: 2 additions & 1 deletion python/pyarrow/_flight.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ cdef class FlightCallOptions(_Weakrefable):
raise TypeError(f"expected IpcReadOptions, got {type(read_options)}")
self.options.read_options = read_options.c_options
if headers is not None:
self.options.headers = headers
self.options.headers = [(tobytes(key), tobytes(value))
for key, value in headers]

@staticmethod
cdef CFlightCallOptions* unwrap(obj):
Expand Down
13 changes: 7 additions & 6 deletions python/pyarrow/tests/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,12 @@ def test_authenticate_basic_token_with_client_middleware():
client.close()


def test_arbitrary_headers_in_flight_call_options():
# GH-35288
@pytest.mark.parametrize("headers", [
[('test-header-1', 'value1'), ('test-header-2', 'value2')],
[(b'test-header-1', b'value1'), (b'test-header-2', b'value2')],
])
def test_arbitrary_headers_in_flight_call_options(headers):
"""Test passing multiple arbitrary headers to the middleware."""
with ArbitraryHeadersFlightServer(
auth_handler=no_op_auth_handler,
Expand All @@ -1743,11 +1748,7 @@ def test_arbitrary_headers_in_flight_call_options():
token_pair = client.authenticate_basic_token(b'test', b'password')
assert token_pair[0] == b'authorization'
assert token_pair[1] == b'Bearer token1234'
options = flight.FlightCallOptions(headers=[
token_pair,
(b'test-header-1', b'value1'),
(b'test-header-2', b'value2')
])
options = flight.FlightCallOptions(headers=[token_pair, *headers])
result = list(client.do_action(flight.Action(
"test-action", b""), options=options))
assert result[0].body.to_pybytes() == b'value1'
Expand Down