Skip to content

Sessions doesn't support multiple headers sharing the same name #1331

Description

@ducaale

Checklist

  • I've searched for similar issues.
  • I'm using the latest version of HTTPie.

Minimal reproduction code and steps

Run http --offline : hello:world hello:people --session test

Current result

The header hello: world is not saved in the session file

$ cat ~/.httpie/sessions/localhost/test.json
{
    "__meta__": {
        "about": "HTTPie session file",
        "help": "https://httpie.io/docs#sessions",
        "httpie": "3.1.0"
    },
    "auth": {
        "password": null,
        "type": null,
        "username": null
    },
    "cookies": [],
    "headers": {
        "hello": "people"
    }
}

Expected result

Both hello: world and hello: people should be saved in the session file


Debug output

Please re-run the command with --debug, then copy the entire command & output and paste both below:

HTTPie 3.1.0
Requests 2.22.0
Pygments 2.7.2
Python 3.8.5 (default, May 27 2021, 13:30:53)
[GCC 9.3.0]
/usr/bin/python3
Linux 5.10.102.1-microsoft-standard-WSL2

<Environment {'apply_warnings_filter': <function Environment.apply_warnings_filter at 0x7ffa8d6de8b0>,
 'as_silent': <function Environment.as_silent at 0x7ffa8d6de790>,
 'colors': 256,
 'config': {'default_options': []},
 'config_dir': PosixPath('/home/ducaale/.httpie'),
 'devnull': <property object at 0x7ffa8d6d8900>,
 'is_windows': False,
 'log_error': <function Environment.log_error at 0x7ffa8d6de820>,
 'program_name': 'http',
 'quiet': 0,
 '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.1.0', 'hello': b'world', 'hello': b'people')>,
 'method': 'get',
 'params': <generator object MultiValueOrderedDict.items at 0x7ffa8d346510>,
 'url': 'http://localhost'})

GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost
User-Agent: HTTPie/3.1.0
hello: world
hello: people


Additional information, screenshots, or code examples

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or enhancementneeds product designWe like the idea, but we want to explore the problem deeper, and consider the solution holistically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions