question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to See Status Code in Output

See original GitHub issue

Checklist

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

Minimal reproduction code and steps

  1. Run local web service that returns 401 for endpoint :8080/get-values
  2. 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:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
isidenticalcommented, Feb 23, 2022

@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 beside auto) changed when we introduced the custom highlighter.

0reactions
jakubroztocilcommented, Feb 22, 2022

@isidentical I think this was introduced with the addition of the Pie theme. Please see #811.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found