Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compat] original httpbin combines mulitple header values into comma-separated string #15

Closed
Tracked by #91
johnroach opened this issue Mar 5, 2019 · 3 comments
Labels
compat Tracking issues around compatibility with original httpbin implementation

Comments

@johnroach
Copy link

johnroach commented Mar 5, 2019

Hi, started using your httpbin thank you for porting this work to Go!

I have been having a problem when using this solution for headers.

I am wondering if you would be OK with simply returning all headers as a string like httpbin instead of setting as list types. It looks like that is the default behavior for httpbin.org

$ curl -H 'foo: bar' -H 'foo: baz' https://httpbin.org/get
{
  "args": {},
  "headers": {
    "Accept": "*/*",
    "Foo": "bar,baz",        <===========================
    "Host": "httpbin.org",
    "User-Agent": "curl/7.54.0"
  },
  ...
  "url": "https://httpbin.org/get"
}

vs

$ curl -H 'foo: bar' -H 'foo: baz' https://httpbin.mccutchen.awesome.com/get
{
   "url" : "https://httpbin.mccutchen.awesome.com/get",
   "origin" : "100.112.202.128",
   "args" : {},
   "headers" : {
      "Foo" : [ "bar", "baz" ],     <===============================

   }
}
@mccutchen
Copy link
Owner

The behavior of the original httpbin service used to be that it would return a single string for single-valued headers or a list of strings for multi-valued headers, and I just adopted the latter form for consistency and ease of implementation. I'm not sure when httpbin switched to returning multiple headers as a single, comma-separated string.

For the moment, I'm 👎 on making this change, because the current behavior seems more "correct" to me. It is an unfortunate break in compatibility with upstream httpbin, though.

Would you mind elaborating on the specific problem you're having with this approach? I want to think about this for a bit, if that's okay!

(And sorry for the delayed reply, I was on vacation for a bit!)

@johnroach
Copy link
Author

No problem about the late reply. I hope you had an awesome vacation!

The issue is that our developers wrote a couple hundred tests against httpbin and I wanted to switch to using yours. However, this incompatibility breaks said tests. That is all really.

If you feel strongly about this I understand. That being said I really hope I can use your solution.

Have a great day!

@mccutchen mccutchen changed the title Regarding returning lists for headers [compat] original httpbin combines mulitple header values into comma-separated string Nov 10, 2022
@mccutchen mccutchen added the compat Tracking issues around compatibility with original httpbin implementation label Nov 11, 2022
@mccutchen
Copy link
Owner

I've taken a pass at this and #37 from time to time over the last couple of years, but I'm never satisfied with the complexity that it requires.

Ultimately, I don't think this (admittedly large) part of backwards-compatibility is worth pursuing, and prefer the consistency of our existing approach: any key-value pair where each key may correspond to one or more values will always be represented as a JSON array (AKA list, slice, etc) with one or more items.

(I'd consider this specific behavior related to handling duplicate headers a bug in the original httpbin, because it potentially loses information.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compat Tracking issues around compatibility with original httpbin implementation
Projects
None yet
Development

No branches or pull requests

2 participants