Unable to See Status Code in Output
See original GitHub issueChecklist
- [ X] I’ve searched for similar issues.
- [ X] I’m using the latest version of HTTPie.
Minimal reproduction code and steps
- Run local web service that returns 401 for endpoint :8080/get-values
- Run HTTPie against endpoint
Current result
Curl output:
$ curl -v 'http://localhost:8080/get-values'
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /get-values HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 401
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Sat, 19 Feb 2022 00:01:22 GMT
<
* Connection #0 to host localhost left intact
* <body redacted>
HTTPie output:
$ http --verbose ':8080/get-values'
GET /get-values HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:8080
User-Agent: HTTPie/3.0.2
HTTP/1.1
Connection: keep-alive
Content-Type: application/json
Date: Sat, 19 Feb 2022 00:02:54 GMT
Keep-Alive: timeout=60
Transfer-Encoding: chunked
<body redacted>
Expected result
Expecting to see HTTP/1.1 401
instead of just HTTP/1.1
.
Debug output
Please re-run the command with --debug
, then copy the entire command & output and paste both below:
$ http --debug ':8080/get-values'
HTTPie 3.0.2
Requests 2.27.1
Pygments 2.11.2
Python 3.10.2 (main, Feb 2 2022, 08:42:42) [Clang 13.0.0 (clang-1300.0.29.3)]
/usr/local/Cellar/httpie/3.0.2/libexec/bin/python3.10
Darwin 20.6.0
<Environment {'as_silent': <function Environment.as_silent at 0x10d7d0f70>,
'colors': 256,
'config': {'default_options': ['--style=fruity']},
'config_dir': PosixPath('/Users/<redacted>/.config/httpie'),
'devnull': <property object at 0x10d7c4cc0>,
'is_windows': False,
'log_error': <function Environment.log_error at 0x10d7d1000>,
'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}>
<PluginManager {'adapters': [],
'auth': [<class 'httpie.plugins.builtin.BasicAuthPlugin'>,
<class 'httpie.plugins.builtin.DigestAuthPlugin'>,
<class 'httpie.plugins.builtin.BearerAuthPlugin'>],
'converters': [],
'formatters': [<class 'httpie.output.formatters.headers.HeadersFormatter'>,
<class 'httpie.output.formatters.json.JSONFormatter'>,
<class 'httpie.output.formatters.xml.XMLFormatter'>,
<class 'httpie.output.formatters.colors.ColorFormatter'>]}>
>>> requests.request(**{'auth': None,
'data': RequestJSONDataDict(),
'headers': <HTTPHeadersDict('User-Agent': b'HTTPie/3.0.2')>,
'method': 'get',
'params': <generator object MultiValueOrderedDict.items at 0x10da93450>,
'url': 'http://localhost:8080/get-values'})
HTTP/1.1
Connection: keep-alive
Content-Type: application/json
Date: Sat, 19 Feb 2022 00:05:16 GMT
Keep-Alive: timeout=60
Transfer-Encoding: chunked
<body redacted>
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Getting curl to output HTTP status code? - Super User
This curl runs in silent mode, follows any redirects, get the HTTP headers. grep will print the HTTP status code to standard output....
Read more >unable to output status_code inside flask restapi
I am using python 3.8, Flask 1.1.2. While trying to handle errors can't figure out a way to return status code and break...
Read more >How to determine status code for a condition
Solved: I want to put in a condition that checks the output status code of the step above it. ... I can't get...
Read more >altool fails with "The auth server returned a bad status code"
Hi All, Trying to validate some altool credentials, produces this error message. "Failed to get authorization for username '<username/>' and password with ...
Read more >Status Code 400 (Bad Request) Explained & How to fix it - Ryte
* 409 conflict: This request by the client is rejected by the server because it was submitted under a false assumption. This status...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@EarthCitizen thanks a lot for sharing the root cause. From that, I was able to make a reproducer via Python’s
http.server
to be used in tests. @jakubroztocil you are right! The handling of HTTP status line in our own lexer (the one that we use for custom themes, e.g anything besideauto
) changed when we introduced the custom highlighter.@isidentical I think this was introduced with the addition of the Pie theme. Please see #811.