File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,6 +82,21 @@ If a server adopts this approach and a client does not specify any codecs in
8282the ` Accept ` header, the server can fall back to checking ` Accept-Encoding `
8383header to pick a compression algorithm for the entire HTTP response stream.
8484
85+ To make debugging easier servers may include the chosen compression codec(s)
86+ in the ` Content-Type ` header of the response (quotes are optional):
87+
88+ Content-Type: application/vnd.apache.arrow.ipc; codecs=zstd
89+
90+ This is not necessary for correct decompression because the payload already
91+ contains information that tells the IPC reader how to decompress the buffers,
92+ but it can help developers understand what is going on.
93+
94+ When programatically checking if the ` Content-Type ` header contains a specific
95+ format, it is important to use a parser that can handle parameters or look
96+ only at the media type part of the header. This is not an exclusivity of the
97+ Arrow IPC format, but a general rule for all media types. For example,
98+ ` application/json; charset=utf-8 ` should be match ` application/json ` .
99+
85100## HTTP/1.1 Response Compression
86101
87102HTTP/1.1 offers an elaborate way for clients to specify their preferred
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ def make_request(uri, compression):
3434 if compression .startswith ("identity+" ):
3535 # request IPC buffer compression instead of HTTP compression
3636 ipc_codec = compression .split ("+" )[1 ]
37- headers ["Accept" ] = f'{ ARROW_STREAM_FORMAT } ;codec ="{ ipc_codec } "'
37+ headers ["Accept" ] = f'{ ARROW_STREAM_FORMAT } ;codecs ="{ ipc_codec } "'
3838 request = urllib .request .Request (uri , headers = headers )
3939
4040 response = urllib .request .urlopen (request )
Original file line number Diff line number Diff line change @@ -524,7 +524,7 @@ def do_GET(self):
524524 self .send_header (
525525 "Content-Type" ,
526526 (
527- f"{ ARROW_STREAM_FORMAT } ; codec ={ compression [9 :]} "
527+ f"{ ARROW_STREAM_FORMAT } ; codecs ={ compression [9 :]} "
528528 if compression .startswith ("identity+" )
529529 else ARROW_STREAM_FORMAT
530530 ),
Original file line number Diff line number Diff line change 2525
2626response = urllib .request .urlopen ('http://localhost:8008' )
2727content_type = response .headers ['Content-Type' ]
28- if content_type != ARROW_STREAM_FORMAT :
28+ if not content_type . startswith ( ARROW_STREAM_FORMAT ) :
2929 raise ValueError (f"Expected { ARROW_STREAM_FORMAT } , got { content_type } " )
3030
3131batches = []
You can’t perform that action at this time.
0 commit comments