@@ -53,6 +53,19 @@ pub fn spawn_eval_thread(
5353 let _ = tx. borrow_mut ( ) . take ( ) ; // This will drop the sender if it wasn't used
5454 } ) ;
5555 let output = result?;
56+
57+ // Content-type inference (when pipeline metadata has no content-type):
58+ //
59+ // | Value type | Content-Type | Conversion |
60+ // |------------------|------------------------|---------------------|
61+ // | Record (__html) | text/html | unwrap __html |
62+ // | Record | application/json | JSON object |
63+ // | List | application/json | JSON array |
64+ // | Binary | application/octet-stream | raw bytes |
65+ // | Empty/Nothing | None (no header) | empty |
66+ // | ListStream | application/x-ndjson | JSONL (if records) |
67+ // | Other | text/html (default) | .to_string() |
68+ //
5669 let inferred_content_type = match & output {
5770 PipelineData :: Value ( Value :: Record { val, .. } , meta)
5871 if meta. as_ref ( ) . and_then ( |m| m. content_type . clone ( ) ) . is_none ( ) =>
@@ -63,12 +76,10 @@ pub fn spawn_eval_thread(
6376 Some ( "application/json" . to_string ( ) )
6477 }
6578 }
66- PipelineData :: Value ( Value :: List { vals, .. } , meta)
67- if meta. as_ref ( ) . and_then ( |m| m. content_type . clone ( ) ) . is_none ( )
68- && !vals. is_empty ( )
69- && vals. iter ( ) . all ( is_jsonl_record) =>
79+ PipelineData :: Value ( Value :: List { .. } , meta)
80+ if meta. as_ref ( ) . and_then ( |m| m. content_type . clone ( ) ) . is_none ( ) =>
7081 {
71- Some ( "application/x-ndjson " . to_string ( ) )
82+ Some ( "application/json " . to_string ( ) )
7283 }
7384 PipelineData :: Value ( Value :: Binary { .. } , meta)
7485 if meta. as_ref ( ) . and_then ( |m| m. content_type . clone ( ) ) . is_none ( ) =>
@@ -98,26 +109,6 @@ pub fn spawn_eval_thread(
98109 let working_set = StateWorkingSet :: new ( & engine. state ) ;
99110 Err ( format_cli_error ( & working_set, error. as_ref ( ) , None ) . into ( ) )
100111 }
101- PipelineData :: Value ( Value :: List { vals, .. } , meta)
102- if !vals. is_empty ( ) && vals. iter ( ) . all ( is_jsonl_record) =>
103- {
104- let http_meta = extract_http_response_meta ( meta. as_ref ( ) ) ;
105- // JSONL: each record as JSON line
106- let jsonl: Vec < u8 > = vals
107- . into_iter ( )
108- . flat_map ( |v| {
109- let mut line = serde_json:: to_vec ( & value_to_json ( & v) ) . unwrap_or_default ( ) ;
110- line. push ( b'\n' ) ;
111- line
112- } )
113- . collect ( ) ;
114- let _ = body_tx. send ( (
115- inferred_content_type,
116- http_meta,
117- ResponseTransport :: Full ( jsonl) ,
118- ) ) ;
119- Ok ( ( ) )
120- }
121112 PipelineData :: Value ( value, meta) => {
122113 let http_meta = extract_http_response_meta ( meta. as_ref ( ) ) ;
123114 let _ = body_tx. send ( (
0 commit comments