X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fde7d98ecdb04b84483288bdc269045eb51193fc..c17bcb844883451b564446bf7843e7b3f862fe48:/src/common/http.cpp?ds=sidebyside diff --git a/src/common/http.cpp b/src/common/http.cpp index a50e3ea140..a7e14752b4 100644 --- a/src/common/http.cpp +++ b/src/common/http.cpp @@ -17,14 +17,15 @@ #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif -#if wxUSE_SOCKETS - #ifndef WX_PRECOMP + #include "wx/defs.h" #endif +#if wxUSE_SOCKETS + #include #include #include "wx/string.h" @@ -116,6 +117,7 @@ void wxHTTP::SendHeaders() bool wxHTTP::ParseHeaders() { wxString line; + wxStringTokenizer tokenzr; m_headers.Clear(); m_read = TRUE; @@ -128,17 +130,12 @@ bool wxHTTP::ParseHeaders() if (line.Length() == 0) break; - wxPrintf(_T("Header: %s\n"), WXSTRINGCAST line); - int pos = line.Find(':'); - if (pos == -1) + tokenzr.SetString(line, " :\t\n\r"); + if (!tokenzr.HasMoreTokens()) return FALSE; - wxString left_str = line(0, pos); - wxString right_str = line(pos+1, line.Length()); - - right_str = right_str.Strip(wxString::leading); - - wxString *str = new wxString(right_str); + wxString left_str = tokenzr.GetNextToken(); + wxString *str = new wxString(tokenzr.GetNextToken()); m_headers.Append(left_str, (wxObject *) str); } @@ -198,10 +195,10 @@ bool wxHTTP::BuildRequest(const wxString& path, wxHTTP_Req req) } SaveState(); + SetFlags(NONE); Notify(FALSE); - SetFlags(WAITALL); - sprintf(buf, "%s %s HTTP/1.0\n\r", tmp_buf, (const char*)pathbuf); + sprintf(buf, "%s %s\n\r", tmp_buf, (const char*) pathbuf); Write(buf, strlen(buf)); SendHeaders(); sprintf(buf, "\n\r"); @@ -278,6 +275,7 @@ wxInputStream *wxHTTP::GetInputStream(const wxString& path) if (!GetHeader(_T("Content-Length")).IsEmpty()) inp_stream->m_httpsize = wxAtoi(WXSTRINGCAST GetHeader(_T("Content-Length"))); + SetFlags(WAITALL); return inp_stream; }