// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "http.h"
#endif
m_read = FALSE;
m_proxy_mode = FALSE;
m_post_buf = wxEmptyString;
+ m_http_response = 0;
SetNotify(wxSOCKET_LOST_FLAG);
}
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;
wxString wxHTTP::GetHeader(const wxString& header) const
{
- wxHeaderIterator it = FindHeader(header);
+ wxHeaderConstIterator it = FindHeader(header);
- return it == m_headers.end() ? wxEmptyString : it->second;
+ return it == m_headers.end() ? wxGetEmptyString() : it->second;
}
void wxHTTP::SetPostBuffer(const wxString& post_buf)
break;
case wxHTTP_POST:
request = wxT("POST");
+ if ( GetHeader( wxT("Content-Length") ).IsNull() )
+ SetHeader( wxT("Content-Length"), wxString::Format( wxT("%lu"), (unsigned long)m_post_buf.Len() ) );
break;
default:
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);
+#if wxUSE_THREADS
+ SetFlags( wxThread::IsMain() ? wxSOCKET_NONE : wxSOCKET_BLOCK );
+#else
+ SetFlags( wxSOCKET_NONE );
+#endif
Notify(FALSE);
wxString buf;
Write("\r\n", 2);
if ( req == wxHTTP_POST ) {
- Write(m_post_buf, m_post_buf.Len());
+ Write(m_post_buf.mbc_str(), m_post_buf.Len());
m_post_buf = wxEmptyString;
}
token.NextToken();
tmp_str2 = token.NextToken();
+ m_http_response = wxAtoi(tmp_str2);
+
switch (tmp_str2[0u]) {
case wxT('1'):
/* INFORMATION / SUCCESS */