X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ab9d6a4c8b9ba090b5b8c77c4afbbbe4043030a1..63e1921d0be4956ab729735189ccf637773a7e27:/src/common/http.cpp diff --git a/src/common/http.cpp b/src/common/http.cpp index 49f08f6dfb..556618aca5 100644 --- a/src/common/http.cpp +++ b/src/common/http.cpp @@ -218,12 +218,20 @@ wxHTTP::SetPostText(const wxString& contentType, const wxString& data, const wxMBConv& conv) { +#if wxUSE_UNICODE wxScopedCharBuffer scb = data.mb_str(conv); - if ( !scb.length() ) + const size_t len = scb.length(); + const char* const buf = scb.data(); +#else // !wxUSE_UNICODE + const size_t len = data.length(); + const char* const buf = data.mb_str(conv); +#endif // wxUSE_UNICODE/!wxUSE_UNICODE + + if ( !len ) return false; m_postBuffer.Clear(); - m_postBuffer.AppendData(scb.data(), scb.length()); + m_postBuffer.AppendData(buf, len); m_contentType = contentType; return true; @@ -380,8 +388,11 @@ bool wxHTTP::BuildRequest(const wxString& path, wxHTTP_Req req) SaveState(); // we may use non blocking sockets only if we can dispatch events from them - SetFlags( wxIsMainThread() && wxApp::IsMainLoopRunning() ? wxSOCKET_NONE - : wxSOCKET_BLOCK ); + int flags = wxIsMainThread() && wxApp::IsMainLoopRunning() ? wxSOCKET_NONE + : wxSOCKET_BLOCK; + // and we must use wxSOCKET_WAITALL to ensure that all data is sent + flags |= wxSOCKET_WAITALL; + SetFlags(flags); Notify(false); wxString buf; @@ -466,7 +477,13 @@ public: size_t m_httpsize; unsigned long m_read_bytes; - wxHTTPStream(wxHTTP *http) : wxSocketInputStream(*http), m_http(http) {} + wxHTTPStream(wxHTTP *http) : wxSocketInputStream(*http) + { + m_http = http; + m_httpsize = 0; + m_read_bytes = 0; + } + size_t GetSize() const { return m_httpsize; } virtual ~wxHTTPStream(void) { m_http->Abort(); }