+ SaveState();
+
+ // we may use non blocking sockets only if we can dispatch events from them
+ SetFlags( wxIsMainThread() && wxApp::IsMainLoopRunning() ? wxSOCKET_NONE
+ : wxSOCKET_BLOCK );
+ Notify(false);
+
+ wxString buf;
+ buf.Printf(wxT("%s %s HTTP/1.0\r\n"), request, path.c_str());
+ const wxWX2MBbuf pathbuf = buf.mb_str();
+ Write(pathbuf, strlen(pathbuf));
+ SendHeaders();
+ Write("\r\n", 2);
+
+ if ( req == wxHTTP_POST ) {
+ Write(m_post_buf.mbc_str(), m_post_buf.Len());
+ m_post_buf = wxEmptyString;
+ }
+
+ wxString tmp_str;
+ m_lastError = ReadLine(this, tmp_str);
+ if (m_lastError != wxPROTO_NOERR) {
+ RestoreState();
+ return false;
+ }
+
+ if (!tmp_str.Contains(wxT("HTTP/"))) {
+ // TODO: support HTTP v0.9 which can have no header.
+ // FIXME: tmp_str is not put back in the in-queue of the socket.
+ m_lastError = wxPROTO_NOERR;
+ SetHeader(wxT("Content-Length"), wxT("-1"));
+ SetHeader(wxT("Content-Type"), wxT("none/none"));
+ RestoreState();
+ return true;
+ }
+
+ wxStringTokenizer token(tmp_str,wxT(' '));
+ wxString tmp_str2;
+ bool ret_value;
+
+ token.NextToken();
+ tmp_str2 = token.NextToken();
+
+ m_http_response = wxAtoi(tmp_str2);
+
+ switch ( tmp_str2[0u].GetValue() )
+ {
+ case wxT('1'):
+ /* INFORMATION / SUCCESS */
+ break;
+
+ case wxT('2'):
+ /* SUCCESS */
+ break;
+
+ case wxT('3'):
+ /* REDIRECTION */
+ break;
+
+ default:
+ m_lastError = wxPROTO_NOFILE;
+ RestoreState();
+ return false;
+ }
+
+ m_lastError = wxPROTO_NOERR;
+ ret_value = ParseHeaders();