Simplify header-parsing code in wxWebResponseCURL

Use BeforeFirst() when we only need to find the first colon instead of
wxSplit().

No real changes (except for pathological case when there is no colon at
all, which wasn't handled correctly by the original code and still
isn't, but in a slightly different way).
This commit is contained in:
Vadim Zeitlin 2020-12-13 02:49:06 +01:00
parent b37c7417f6
commit 7b7f9fa6c0

View File

@ -89,14 +89,10 @@ size_t wxWebResponseCURL::AddHeaderData(const char * buffer, size_t size)
}
else if ( !hdr.empty() )
{
wxArrayString hdrArr = wxSplit(hdr, ':');
wxString hdrName;
wxString hdrValue;
if ( hdrArr.size() > 0 )
hdrName = hdrArr[0].Trim().MakeUpper();
if ( hdrArr.size() > 1 )
hdrValue = hdrArr[1].Trim(false);
m_headers[hdrName] = hdrValue;
wxString hdrName = hdr.BeforeFirst(':', &hdrValue).Strip(wxString::trailing);
hdrName.MakeUpper();
m_headers[hdrName] = hdrValue.Strip(wxString::leading);
}
return size;