cli icon indicating copy to clipboard operation
cli copied to clipboard

Intermediate requests are being printed if `--print=H` flag is used

Open ducaale opened this issue 4 years ago • 3 comments

Checklist

  • [x] I've searched for similar issues.
  • [x] I'm using the the latest version of HTTPie.

What are the steps to reproduce the problem?

Run http --follow --print=H pie.dev/redirect/3

What is the expected result?

I should only see the ~~last~~ first request header

What happens instead?

Intermediate request headers are shown but there is no mention in the docs that --print implies --all

Debug output

Please re-run the command with --debug, then copy the entire command & output and paste both below:

$ http --debug --follow --print=H pie.dev/redirect/3
HTTPie 2.4.0
Requests 2.22.0
Pygments 2.7.2
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0]
/usr/bin/python3
Linux 4.19.104-microsoft-standard

<Environment {'colors': 256,
 'config': {'__meta__': {'about': 'HTTPie configuration file',
                         'help': 'https://httpie.org/doc#config',
                         'httpie': '1.0.3'},
            'default_options': []},
 'config_dir': PosixPath('/home/ducaale/.httpie'),
 'devnull': <property object at 0x7fab34b27bd0>,
 'is_windows': False,
 'log_error': <function Environment.log_error at 0x7fab34b29d30>,
 'program_name': 'http',
 'stderr': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>,
 'stderr_isatty': True,
 'stdin': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>,
 'stdin_encoding': 'utf-8',
 'stdin_isatty': True,
 'stdout': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>,
 'stdout_encoding': 'utf-8',
 'stdout_isatty': True}>

>>> requests.request(**{'auth': None,
 'data': RequestJSONDataDict(),
 'headers': {'User-Agent': b'HTTPie/2.4.0'},
 'method': 'get',
 'params': <generator object MultiValueOrderedDict.items at 0x7fab34a9dba0>,
 'url': 'http://pie.dev/redirect/3'})

GET /redirect/3 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: pie.dev
User-Agent: HTTPie/2.4.0

GET /relative-redirect/2 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: pie.dev
User-Agent: HTTPie/2.4.0

GET /relative-redirect/1 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: pie.dev
User-Agent: HTTPie/2.4.0

GET /get HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: pie.dev
User-Agent: HTTPie/2.4.0

Provide any additional information, screenshots, or code examples below: N/A

ducaale avatar Jun 01 '21 18:06 ducaale

Hello @ducaale,

Thanks for the report.

After digging into the issue, it appears to be a little bit complicated to handle that scenario. I do not say we will not fix it, but it requires to adapt how requests are printed and we like the way it is as of now: streamed in real-time. I simply added a reproduction test case with 9792513c6878a410fe7645810668f820100b5eea and delayed the work on a potential solution for now because we have more important priorities.

Just keep the issue open and we will come back in the future with a solution :)

BoboTiG avatar Jun 09 '21 12:06 BoboTiG

I should only see the last request header

Hm, would you expect to only see the last request? That's how --all is documented, but seeing only the first request and the final response is what I'd intuitively expect.

(Context: we're implementing --all in ducaale/xh#137 and aren't sure about the correct behavior)

blyxxyz avatar Jun 09 '21 12:06 blyxxyz

seeing only the first request and the final response is what I'd intuitively expect.

This is how https://github.com/ducaale/xh/pull/137 is currently being implemented

  • By default, the first request and last response are printable
  • --all can mark intermediate responses and requests as printable
  • --print affects any request and response that is marked as printable
  • --history-print affects intermediate requests and responses which are marked as printable
  • --verbose implies --all

I am not sure why I said last request instead of first request in the bug report .

ducaale avatar Jun 09 '21 12:06 ducaale