mirror of
https://github.com/httpie/cli.git
synced 2024-11-24 08:22:22 +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
|
||||
|
||||
|
||||
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):
|
||||
|
||||
installed_processors = [
|
||||
JSONProcessor,
|
||||
HeadersProcessor,
|
||||
PygmentsProcessor
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user