lidavidm commented on a change in pull request #7224:
URL: https://github.com/apache/arrow/pull/7224#discussion_r428637604
##########
File path: python/pyarrow/_flight.pyx
##########
@@ -1785,15 +1786,16 @@ cdef dict convert_headers(const CCallHeaders&
c_headers):
CCallHeaders.const_iterator header_iter = c_headers.cbegin()
headers = {}
while header_iter != c_headers.cend():
- # Headers in gRPC (and HTTP/1, HTTP/2) are required to be
- # valid ASCII.
header = c_string(deref(header_iter).first).decode("ascii")
+ if header not in headers:
+ headers[header] = []
+ value = c_string(deref(header_iter).second)
if not header.endswith("-bin"):
- # Ignore -bin (gRPC binary) headers
- value = c_string(deref(header_iter).second).decode("ascii")
- if header not in headers:
- headers[header] = []
- headers[header].append(value)
+ # Text header values in gRPC (and HTTP/1, HTTP/2) are
+ # required to be valid ASCII. Binary header values are
+ # exposed as bytes.
+ value = value.decode("ascii")
+ headers[header].append(value)
Review comment:
Good catch, thank you!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]