Skip to content

Commit e1f7f48

Browse files
committed
Remove pretty print for streaming
1 parent bcde87d commit e1f7f48

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

api/client.go

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,6 @@ func (c *ApiClient) StreamRequest(method, endpoint string, headers []string, dat
365365
return xurlErrors.NewAPIError(js)
366366
}
367367

368-
contentType = resp.Header.Get("Content-Type")
369-
isJSON := strings.Contains(contentType, "application/json") ||
370-
strings.Contains(contentType, "application/x-ndjson") ||
371-
strings.Contains(contentType, "application/stream+json")
372-
373368
scanner := bufio.NewScanner(resp.Body)
374369

375370
const maxScanTokenSize = 1024 * 1024
@@ -385,22 +380,8 @@ func (c *ApiClient) StreamRequest(method, endpoint string, headers []string, dat
385380
if line == "" {
386381
continue
387382
}
388-
389-
if isJSON {
390-
var js json.RawMessage
391-
if err := json.Unmarshal([]byte(line), &js); err != nil {
392-
fmt.Println(line)
393-
} else {
394-
prettyJSON, err := json.MarshalIndent(js, "", " ")
395-
if err != nil {
396-
fmt.Println(line)
397-
} else {
398-
fmt.Println(string(prettyJSON))
399-
}
400-
}
401-
} else {
402-
fmt.Println(line)
403-
}
383+
// We can't pretty-print streaming responses
384+
fmt.Println(line)
404385
}
405386

406387
if err := scanner.Err(); err != nil {

0 commit comments

Comments
 (0)