1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1508, Transform http header name to upper camel case. 4.0.54

This commit is contained in:
winlin 2020-11-11 16:38:05 +08:00
parent 07c04a042a
commit 9908433bc8
3 changed files with 18 additions and 1 deletions

View file

@ -154,6 +154,22 @@ SrsHttpHeader::~SrsHttpHeader()
void SrsHttpHeader::set(string key, string value)
{
// Convert to UpperCamelCase, for example:
// transfer-encoding
// transform to:
// Transfer-Encoding
char pchar = 0;
for (int i = 0; i < (int)key.length(); i++) {
char ch = key.at(i);
if (i == 0 || pchar == '-') {
if (ch >= 'a' && ch <= 'z') {
((char*)key.data())[i] = ch - 32;
}
}
pchar = ch;
}
headers[key] = value;
}