Skip to content

Commit 140ced0

Browse files
badGarnetclaude
andcommitted
docs: correct why the unsplit path receives JSON
The API does not negotiate response format on Accept at all: it reads the output_format form field, and only consults Accept to select multipart/mixed and to reject conflicting media types on multi-file uploads. Saying the spec merely omits application/x-ndjson understated it -- NDJSON was never going to arrive via Accept regardless of what the spec declared. Comment only; no behavior change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent ba3e7f4 commit 140ced0

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎src/unstructured_client/general.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ def _ndjson_requested(request: httpx.Request) -> bool:
5252
def _json_body_to_elements_file(http_res: httpx.Response) -> str:
5353
"""Write a JSON-array body out as NDJSON, so `elements_file` is set either way.
5454
55-
The deployed API does not offer `application/x-ndjson`: its spec declares only
56-
`application/json` and `text/csv`, so a request that skips the split-PDF hook comes
57-
back as JSON no matter what was asked for. Without this, opting into NDJSON would
58-
silently populate `elements` instead and leave `elements_file` as None, forcing every
59-
caller to handle both shapes for one flag.
55+
The deployed API does not offer `application/x-ndjson`, and does not in fact negotiate
56+
the response format on `Accept` at all -- it reads the `output_format` form field, and
57+
only consults `Accept` to select `multipart/mixed` and to reject conflicting media
58+
types on multi-file uploads. So a request that skips the split-PDF hook comes back as
59+
JSON no matter what was asked for. Without this, opting into NDJSON would silently
60+
populate `elements` instead and leave `elements_file` as None, forcing every caller to
61+
handle both shapes for one flag.
6062
6163
This does not bound memory -- the body is already fully read by the time we get here,
6264
and parsing it adds the element list on top. It exists to keep the contract uniform.

0 commit comments

Comments
 (0)