ducaale / xh

Friendly and fast tool for sending HTTP requests
MIT License
4.96k stars 90 forks source link

JSON pretty printing inserts extra newline #349

Open eproxus opened 5 months ago

eproxus commented 5 months ago

Compare:

$ xh get https://jsonplaceholder.typicode.com/todos/1
HTTP/2.0 200 OK
...headers...

{
    "userId": 1,
    "id": 1,
    "title": "delectus aut autem",
    "completed": false
}

$

With:

$ xh get google.com
HTTP/1.1 301 Moved Permanently
...headers...

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

$

(Maybe the last newline should be stripped in the HTML case too?)

zuisong commented 2 months ago

This is intentional. see #109

eproxus commented 2 months ago

Is it really needed at the end of the output? It feels like it just wastes space in the terminal... 🙂 (I can see the need between bodies/chunks, but not at the end of the output).

blyxxyz commented 2 months ago

Related: https://github.com/httpie/cli/issues/1547