Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--no-output overrides --include: only show headers of the response #3421

Open
Jiehong opened this issue Nov 20, 2024 · 1 comment
Open

--no-output overrides --include: only show headers of the response #3421

Jiehong opened this issue Nov 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Jiehong
Copy link

Jiehong commented Nov 20, 2024

What is the current bug behavior?

Running echo 'GET https://www.wikipedia.org' | hurl --include --no-output shows nothing on stdout, yet headers should be displayed.

What is the expected correct behavior?

Body should not be printed, but headers should.

Execution context

  • Hurl Version (hurl --version):
hurl --version
hurl 5.0.1 (x86_64-apple-darwin23.0) libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.61.0
Features (libcurl):  alt-svc AsynchDNS HSTS HTTP2 IPv6 Largefile libz NTLM SPNEGO SSL UnixSockets
Features (built-in): brotli

Possible fixes

A workaround exists for the http method GET: use HEAD instead.

However, this does not work with PUT or POST for example.

There should be a way to only display the response headers without the body.

Perhaps a new option --no-body could be introduced.

Note: the manual entry for --no-output seems partially misleading, and talks about the body:

       --no-output

              Suppress output. By default, Hurl outputs the body of the last response.

              This is a cli-only option.
@Jiehong Jiehong added the bug Something isn't working label Nov 20, 2024
@jcamiel
Copy link
Collaborator

jcamiel commented Nov 20, 2024

Hi @Jiehong

I think curl's --include output headers on stdout.

For instance:

$ curl http://localhost:8000/hello
Hello World!%       
$ curl --include http://localhost:8000/hello
HTTP/1.1 200 OK
Server: Werkzeug/3.0.6 Python/3.12.4
Date: Wed, 20 Nov 2024 13:56:41 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 12
Server: Flask Server
Connection: close

Hello World!%       
$ curl --include --output /dev/null http://localhost:8000/hello
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    12  100    12    0     0   5842      0 --:--:-- --:--:-- --:--:--  6000

So when curl uses --include and --output /dev/null, it doesn't display headers.
Given this, we want Hurl to work as curl so it makes sense that echo 'GET http://localhost:8000/hello' | hurl --include --output /dev/null is displaying nothing.

Now, you may want to display only headers. A potential solution will be (as mentionned in #1745) to implement --dump-header or --write-out:

$ curl --dump-header - --silent --output /dev/null http://localhost:8000/hello
HTTP/1.1 200 OK
Server: Werkzeug/3.0.6 Python/3.12.4
Date: Wed, 20 Nov 2024 14:04:30 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 12
Server: Flask Server
Connection: close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants