mirror of
https://github.com/httpie/cli.git
synced 2025-06-21 10:07:47 +02:00
Sort headers by name when prettifying.
This commit is contained in:
parent
4b1a04e5ed
commit
4615011f2e
@ -224,10 +224,23 @@ class PygmentsProcessor(BaseProcessor):
|
|||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
|
class HeadersProcessor(BaseProcessor):
|
||||||
|
"""
|
||||||
|
Sorts headers by name retaining relative order of multiple headers
|
||||||
|
with the same name.
|
||||||
|
|
||||||
|
"""
|
||||||
|
def process_headers(self, headers):
|
||||||
|
lines = headers.splitlines()
|
||||||
|
headers = sorted(lines[1:], key=lambda h: h.split(':')[0])
|
||||||
|
return '\n'.join(lines[:1] + headers)
|
||||||
|
|
||||||
|
|
||||||
class OutputProcessor(object):
|
class OutputProcessor(object):
|
||||||
|
|
||||||
installed_processors = [
|
installed_processors = [
|
||||||
JSONProcessor,
|
JSONProcessor,
|
||||||
|
HeadersProcessor,
|
||||||
PygmentsProcessor
|
PygmentsProcessor
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user