From 7b7f9fa6c0d158246665028f6d638da5d6646b3e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 Dec 2020 02:49:06 +0100 Subject: [PATCH] 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). --- src/common/webrequest_curl.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/common/webrequest_curl.cpp b/src/common/webrequest_curl.cpp index 6c04d1eeee..b62aa3241a 100644 --- a/src/common/webrequest_curl.cpp +++ b/src/common/webrequest_curl.cpp @@ -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;