Response Header Name issue.
As per the HTTP response headers list, the first letter of the header should be in Capital case but, I am seeing all headers in lowercase in Bruno's response. Please let me know if there config to change the same. Thanks.
We could add an Option to automatically "prettify" Header names, but the casing for headers does not matter anyway.
https://www.rfc-editor.org/rfc/rfc9110.html#section-5.1 / https://www.rfc-editor.org/rfc/rfc9110.html#section-6.3
Field names are case-insensitive and ought to be registered within the "Hypertext Transfer Protocol (HTTP) Field Name Registry"; see Section 16.3.1.
Oh, this is trippy. I literally just opened #2012 which is quite similar.
I think @Its-treason is right. As HTTP headers are supposed to be case-insensitive anyway, having Bruno always lowercase the header's name is reasonable. It just has to be accounted for when fetching the name with res.getHeader(). My recommendation in #2012 was to update the docs to clearly articulate that.
I don't think we want to prettify header names. We either have to honor what is sent back from the server, or always lowercase it. By lowercasing it, we never have to do a .toLowerCase() on a potentially undefined header name which would throw an exception anyways.
I think you're right, changing/"prettifying" the casing of headers, would just cause confusion, so we should just leave everything lowercase.
Yes. I would agree that it is case insensitive. I am new to bruno and I was referring insomnia scripts to get response header. I got undefined for Authorization name but I got correct value for authorization. Just for curiousity, is there any provision where it should return same response header for Authorization and authorization based on case insensitive logic 🤔
I don't think there is an official provision, other than the HTTP spec saying headers are case-insensitive. Our library (axios) just lowercases all header names. But we should clarify this in the documentation.
How about
class BrunoResponse {
// ...
getHeader(name) {
return this.res && this.res.headers ? (this.res.headers[name] || this.res.headers[name.toLowerCase()]) : null;
}
// ...
}
or even
class BrunoResponse {
// ...
getHeader(name) {
return this.res && this.res.headers ? this.res.headers[name.toLowerCase()] : null;
}
// ...
}
if it is guaranteed that axios will always lower case the header names?
This would be great suggestion and it will resolve the problem of script migration from postman/insomnia to bruno. 👍
@lanthoor Axios always lowercases the header names: https://axios-http.com/docs/res_schema