X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/01482482504acd002914a8385cf8906c3f4d8648..44fd6f721ad375033b2a2b64ac5f703ac70cb8f0:/src/common/http.cpp diff --git a/src/common/http.cpp b/src/common/http.cpp index 9758181c72..d5fa45d6bd 100644 --- a/src/common/http.cpp +++ b/src/common/http.cpp @@ -9,7 +9,7 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "http.h" #endif @@ -44,6 +44,7 @@ wxHTTP::wxHTTP() m_read = FALSE; m_proxy_mode = FALSE; m_post_buf = wxEmptyString; + m_http_response = 0; SetNotify(wxSOCKET_LOST_FLAG); } @@ -70,13 +71,22 @@ void wxHTTP::SetProxyMode(bool on) m_proxy_mode = on; } -wxHTTP::wxHeaderIterator wxHTTP::FindHeader(const wxString& header) const +wxHTTP::wxHeaderIterator wxHTTP::FindHeader(const wxString& header) { - // we can't convert between const_iterator to iterator otherwise... - wxStringToStringHashMap& headers = (wxStringToStringHashMap&)m_headers; + wxHeaderIterator it = m_headers.begin(); + for ( wxHeaderIterator en = m_headers.end(); it != en; ++it ) + { + if ( wxStricmp(it->first, header) == 0 ) + break; + } + + return it; +} - wxHeaderIterator it = headers.begin(); - for ( wxHeaderIterator en = headers.end(); it != en; ++it ) +wxHTTP::wxHeaderConstIterator wxHTTP::FindHeader(const wxString& header) const +{ + wxHeaderConstIterator it = m_headers.begin(); + for ( wxHeaderConstIterator en = m_headers.end(); it != en; ++it ) { if ( wxStricmp(it->first, header) == 0 ) break; @@ -101,7 +111,7 @@ void wxHTTP::SetHeader(const wxString& header, const wxString& h_data) wxString wxHTTP::GetHeader(const wxString& header) const { - wxHeaderIterator it = FindHeader(header); + wxHeaderConstIterator it = FindHeader(header); return it == m_headers.end() ? wxGetEmptyString() : it->second; } @@ -213,9 +223,11 @@ bool wxHTTP::BuildRequest(const wxString& path, wxHTTP_Req req) return FALSE; } + m_http_response = 0; + // If there is no User-Agent defined, define it. if (GetHeader(wxT("User-Agent")).IsNull()) - SetHeader(wxT("User-Agent"), wxT("wxWindows 2.x")); + SetHeader(wxT("User-Agent"), wxT("wxWidgets 2.x")); SaveState(); SetFlags(wxSOCKET_NONE); @@ -256,6 +268,8 @@ bool wxHTTP::BuildRequest(const wxString& path, wxHTTP_Req req) token.NextToken(); tmp_str2 = token.NextToken(); + m_http_response = wxAtoi(tmp_str2); + switch (tmp_str2[0u]) { case wxT('1'): /* INFORMATION / SUCCESS */