question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update naming for header methods on requests

See original GitHub issue

The putHeaders/withHeaders methods are confusing for multiple people.

Let’s deprecate them and add addHeaders and replaceHeaders methods respectively. Those names have immediately-obvious semantics.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
rossabakercommented, Jan 12, 2021

There are a lot of ways to do this, so let’s try to be a bit more rigorous in our definitions.

  1. Some headers are recurring (e.g., Accept), and some are singletons (e.g., Content-Length). A recurring header can have multiple instances. A singleton header only sensibly has one.
  2. Every recurring header can be combined into a single header by joining their values with a comma, except Set-Cookie, because our forebears hated us and wanted us to be unhappy.
  3. The semantics depend on the key.

I’m going to intentionally avoid our existing names for things here, because I can’t remember what the damn things do. But there are several possible implementations of (a: Headers, b: Headers) => Headers. Which ones do we want, and what should they be called?

  1. Append a to b, regardless of semantics.
  2. Combine headers by key in a and b, joining duplicates with a comma, regardless of semantics.
  3. Replace singletons from a with b. Append recurring headers from b to b. Keep other headers from a.
  4. Replace singletons from a with b. Combine recurring headers by key in a and b. Keep other headers from a.
  5. Replace all headers from a with b. Keep other headers from a.
  6. Return b
  7. ???
0reactions
rossabakercommented, Dec 15, 2021

I’m not aware of any active effort to change them from 0.23. Is there something you’d still like to see?

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP headers - MDN Web Docs - Mozilla
Request headers contain more information about the resource to be fetched, or about the client requesting the resource. · Response headers hold ...
Read more >
Custom HTTP headers : naming conventions - Stack Overflow
The recommendation is was to start their name with "X-". E.g. X-Forwarded-For , X-Requested-With . This is also mentioned in a.o. section 5 ......
Read more >
Specifying HTTP headers - IBM
To specify the content types of the request body and output, use the Content-Type and Accept headers. Table 1. Content-Type and Accept header...
Read more >
HTTP/1.1: Header Field Definitions
The Accept request-header field can be used to specify certain media types which are acceptable for the response. Accept headers can be used...
Read more >
HTTP Request Methods – Get vs Put vs Post Explained with ...
Select the PATCH request method. 3. In the Headers tab, set accept as a header and set the value to application/vnd.github.v3+json .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found