You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the HTTP code snippet is generated, it is generated with the first letter in uppercase and the format should be the same as in the header. A difference if the type CURL is selected maintains the correct format.
To Reproduce
Execute a example of request.
Clic in code snipper {}.
In code select HTTP.
Expected behavior
The expected behavior is to keep the same format as the header, as is done in the CURL.
Platform:
OS: Windows 10
vscode version: 1.66.2
extension version: 1.18.7
@dimitropoulos
Please advise whether the capitalization of HTTP headers is needed at httpsnippet.
As HTTP Headers are case sensitive, we think this transformation (toUpperCase()) should not be done. It is preventing us from using the httpsnippet with the expected result and causing header capitalization caused errors while using the http code generated by httpsnippet.
This is the code section we don't understand, and even there is commented that it is not required. Shouldn't it be deleted, then?
// Capitalize header keys, even though it's not required by the spec.
const keyCapitalized = key.toLowerCase().replace(/(^|-)(\w)/g, input => input.toUpperCase());
push(${keyCapitalized}: ${allHeaders[key]});
Just as in HTTP/1.x, header field names are strings of ASCII characters
that are compared in a case-insensitive fashion. However, header field
names MUST be converted to lowercase prior to their encoding in HTTP/2.
A request or response containing uppercase header field names MUST
be treated as malformed.
and just keep the header as-is presumably because whatever server they're using is expecting those custom headers to be lower case.
If you input "operation-date", it should output "operation-date", but in this case the HTTP target is needlessly capitalizing all headers, including that header name too, to Operation-Date. The curl target correctly preserves the case and outputs operation-date.
Activity
jaroga86 commentedon Sep 23, 2022
@dimitropoulos
Please advise whether the capitalization of HTTP headers is needed at httpsnippet.
As HTTP Headers are case sensitive, we think this transformation (toUpperCase()) should not be done. It is preventing us from using the httpsnippet with the expected result and causing header capitalization caused errors while using the http code generated by httpsnippet.
This is the code section we don't understand, and even there is commented that it is not required. Shouldn't it be deleted, then?
// Capitalize header keys, even though it's not required by the spec.
const keyCapitalized = key.toLowerCase().replace(/(^|-)(\w)/g, input => input.toUpperCase());
push(
${keyCapitalized}: ${allHeaders[key]});erunion commentedon Oct 3, 2022
@jaroga86 HTTP headers are case-insensitive in HTTP/1.1:
However in HTTP/2 they must be lowercased:
verhovsky commentedon Feb 25, 2023
The user wants you to remove this line
httpsnippet/src/targets/http/http1.1/client.ts
Line 59 in cee79a5
and just keep the header as-is presumably because whatever server they're using is expecting those custom headers to be lower case.
If you input "
operation-date", it should output "operation-date", but in this case the HTTP target is needlessly capitalizing all headers, including that header name too, toOperation-Date. The curl target correctly preserves the case and outputsoperation-date.