Fix encoding error with non-prettified encoded responses#1168
Fix encoding error with non-prettified encoded responses#1168
Conversation
Removed `--format-option response.as` an promote `--response-as`: using the format option would be misleading as it is now also used by non-prettified responses.
Codecov Report
@@ Coverage Diff @@
## master #1168 +/- ##
==========================================
- Coverage 97.28% 96.66% -0.62%
==========================================
Files 67 70 +3
Lines 4235 4471 +236
==========================================
+ Hits 4120 4322 +202
- Misses 115 149 +34
Continue to review full report at Codecov.
|
* split --response-as into --response-mime and --response-charset * add support for Content-Type charset for requests printed to terminal * add support charset detection for requests printed to terminal without a Content-Type charset * etc.
httpie/encoding.py
Outdated
| >>> too_short = ']"foo"' | ||
| >>> detected = from_bytes(too_short.encode()).best().encoding | ||
| >>> detected | ||
| 'utf_16_be' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
That’s exactly what we needed. Is there still some length threshold below which it’s unreasonable to rely on the detected encoding? Or a way to get some sort of confidence interval for the best match?
There was a problem hiding this comment.
Maybe could we require charset_normalizer>=2.0.5 and drop our own TOO_SMALL_SEQUENCE check?
I am not sure that charset_normalizer >= 2.0.5 is available on all OSes for our package thought.
There was a problem hiding this comment.
I committed d52a483 just to see how it goes.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
I'll revert d52a483 as it seems too new.
Proposal
Content-Typechecks from thePrettyStreamclass to theEncodedStreamparent class.--format-option response.asand--response-asoptions.--response-encodingand--response-mimeoptions.Fixes #1167.