HttpHeaders: header field names are case insensitive.
Whitespace before and after tokens should be ignored.
This commit is contained in:
@@ -7,7 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
@@ -37,10 +38,10 @@ BHttpHeader::BHttpHeader(const char* string)
|
|||||||
|
|
||||||
BHttpHeader::BHttpHeader(const char* name, const char* value)
|
BHttpHeader::BHttpHeader(const char* name, const char* value)
|
||||||
:
|
:
|
||||||
fName(name),
|
|
||||||
fValue(value),
|
|
||||||
fRawHeaderValid(false)
|
fRawHeaderValid(false)
|
||||||
{
|
{
|
||||||
|
SetName(name);
|
||||||
|
SetValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ BHttpHeader::SetName(const char* name)
|
|||||||
{
|
{
|
||||||
fRawHeaderValid = false;
|
fRawHeaderValid = false;
|
||||||
fName = name;
|
fName = name;
|
||||||
|
fName.Trim().CapitalizeEachWord();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -66,27 +68,25 @@ BHttpHeader::SetValue(const char* value)
|
|||||||
{
|
{
|
||||||
fRawHeaderValid = false;
|
fRawHeaderValid = false;
|
||||||
fValue = value;
|
fValue = value;
|
||||||
|
fValue.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BHttpHeader::SetHeader(const char* string)
|
BHttpHeader::SetHeader(const char* string)
|
||||||
{
|
{
|
||||||
BString strLine(string);
|
|
||||||
|
|
||||||
fRawHeaderValid = false;
|
fRawHeaderValid = false;
|
||||||
fName.Truncate(0);
|
fName.Truncate(0);
|
||||||
fValue.Truncate(0);
|
fValue.Truncate(0);
|
||||||
|
|
||||||
int32 separatorLocation = strLine.FindFirst(": ");
|
const char* separator = strchr(string, ':');
|
||||||
|
|
||||||
if (separatorLocation == B_ERROR)
|
if (separator == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
strLine.MoveInto(fName, 0, separatorLocation);
|
fName.SetTo(string, separator - string);
|
||||||
strLine.Remove(0, 2);
|
fName.Trim().CapitalizeEachWord();
|
||||||
fValue = strLine;
|
SetValue(separator + 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ BHttpHeader::Header() const
|
|||||||
bool
|
bool
|
||||||
BHttpHeader::NameIs(const char* name) const
|
BHttpHeader::NameIs(const char* name) const
|
||||||
{
|
{
|
||||||
return fName == BString(name);
|
return fName == BString(name).Trim().CapitalizeEachWord();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user