mirror of
https://github.com/httpie/cli.git
synced 2024-12-01 20:23:42 +01:00
e4c68063b9
Still work in progress and the API should be considered private for now.
15 lines
412 B
Python
15 lines
412 B
Python
from httpie.plugins import FormatterPlugin
|
|
|
|
|
|
class HeadersFormatter(FormatterPlugin):
|
|
|
|
def format_headers(self, headers):
|
|
"""
|
|
Sorts headers by name while retaining relative
|
|
order of multiple headers with the same name.
|
|
|
|
"""
|
|
lines = headers.splitlines()
|
|
headers = sorted(lines[1:], key=lambda h: h.split(':')[0])
|
|
return '\r\n'.join(lines[:1] + headers)
|