summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ed17561)
* Added two missing "virtual" in stream.h (Sorry, you'll have to rebuild all)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1812
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// IO functions
virtual char Peek();
char GetC();
// IO functions
virtual char Peek();
char GetC();
- wxInputStream& Read(void *buffer, size_t size);
+ virtual wxInputStream& Read(void *buffer, size_t size);
wxInputStream& Read(wxOutputStream& stream_out);
// Position functions
wxInputStream& Read(wxOutputStream& stream_out);
// Position functions
wxOutputStream(wxStreamBuffer *sbuf);
virtual ~wxOutputStream();
wxOutputStream(wxStreamBuffer *sbuf);
virtual ~wxOutputStream();
- wxOutputStream& Write(const void *buffer, size_t size);
+ virtual wxOutputStream& Write(const void *buffer, size_t size);
wxOutputStream& Write(wxInputStream& stream_in);
off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart);
wxOutputStream& Write(wxInputStream& stream_in);
off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart);
if (line.Length() == 0)
break;
if (line.Length() == 0)
break;
+ printf("Header: %s\n", WXSTRINGCAST line);
int pos = line.Find(':');
if (pos == -1)
return FALSE;
int pos = line.Find(':');
if (pos == -1)
return FALSE;
+ SaveState();
+ Notify(FALSE);
+ SetFlags(WAITALL);
+
sprintf(buf, "%s %s HTTP/1.0\n\r", tmp_buf, (const char *)path);
Write(buf, strlen(buf));
SendHeaders();
sprintf(buf, "%s %s HTTP/1.0\n\r", tmp_buf, (const char *)path);
Write(buf, strlen(buf));
SendHeaders();
wxString tmp_str;
m_error = GetLine(this, tmp_str);
wxString tmp_str;
m_error = GetLine(this, tmp_str);
- if (m_error != wxPROTO_NOERR)
+ if (m_error != wxPROTO_NOERR) {
+ RestoreState();
if (!tmp_str.Contains("HTTP/")) {
// TODO: support HTTP v0.9 which can have no header.
SetHeader("Content-Length", "-1");
SetHeader("Content-Type", "none/none");
if (!tmp_str.Contains("HTTP/")) {
// TODO: support HTTP v0.9 which can have no header.
SetHeader("Content-Length", "-1");
SetHeader("Content-Type", "none/none");
return TRUE;
}
wxStringTokenizer token(tmp_str,' ');
wxString tmp_str2;
return TRUE;
}
wxStringTokenizer token(tmp_str,' ');
wxString tmp_str2;
token.NextToken();
tmp_str2 = token.NextToken();
token.NextToken();
tmp_str2 = token.NextToken();
break;
default:
m_error = wxPROTO_NOFILE;
break;
default:
m_error = wxPROTO_NOFILE;
+ ret_value = ParseHeaders();
+ RestoreState();
+ return ret_value;
}
class wxHTTPStream : public wxSocketInputStream {
}
class wxHTTPStream : public wxSocketInputStream {
size_t m_httpsize;
wxHTTPStream(wxHTTP *http) : wxSocketInputStream(*http), m_http(http) {}
size_t m_httpsize;
wxHTTPStream(wxHTTP *http) : wxSocketInputStream(*http), m_http(http) {}
- size_t StreamSize() { return m_httpsize; }
+ size_t StreamSize() const { return m_httpsize; }
virtual ~wxHTTPStream(void) { m_http->Abort(); }
};
virtual ~wxHTTPStream(void) { m_http->Abort(); }
};
if (!BuildRequest(path, wxHTTP_GET))
return NULL;
if (!BuildRequest(path, wxHTTP_GET))
return NULL;
- if (GetHeader("Content-Length").IsEmpty())
+ printf("Len = %s\n", WXSTRINGCAST GetHeader("Content-Length"));
+ if (!GetHeader("Content-Length").IsEmpty())
inp_stream->m_httpsize = atoi(WXSTRINGCAST GetHeader("Content-Length"));
return inp_stream;
inp_stream->m_httpsize = atoi(WXSTRINGCAST GetHeader("Content-Length"));
return inp_stream;
////////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "socket.h"
////////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "socket.h"
-// #pragma interface
-// #pragma implementation "socket.cpp"
wxSocketBase& wxSocketBase::Read(char* buffer, size_t nbytes)
{
wxSocketBase& wxSocketBase::Read(char* buffer, size_t nbytes)
{
- m_lcount = GetPushback(buffer, nbytes, FALSE);
- nbytes -= m_lcount;
+ size_t count;
+
+ count = GetPushback(buffer, nbytes, FALSE);
+ nbytes -= count;
+ buffer += count;
// If we have got the whole needed buffer or if we don't want to
// wait then it returns immediately.
if (!nbytes || (m_lcount && !(m_flags & WAITALL)) )
return *this;
// If we have got the whole needed buffer or if we don't want to
// wait then it returns immediately.
if (!nbytes || (m_lcount && !(m_flags & WAITALL)) )
return *this;
WantBuffer(buffer, nbytes, EVT_READ);
WantBuffer(buffer, nbytes, EVT_READ);
return *this;
}
wxSocketBase& wxSocketBase::Peek(char* buffer, size_t nbytes)
{
return *this;
}
wxSocketBase& wxSocketBase::Peek(char* buffer, size_t nbytes)
{
- size_t nbytes_old = nbytes;
- nbytes -= GetPushback(buffer, nbytes, TRUE);
- if (!nbytes)
+ count = GetPushback(buffer, nbytes, TRUE);
+ if (nbytes-count == 0)
+ buffer += count;
+ nbytes -= count;
WantBuffer(buffer, nbytes, EVT_PEEK);
WantBuffer(buffer, nbytes, EVT_PEEK);
curr_pos = new_buf + size;
memcpy(new_buf, buffer, size);
curr_pos = new_buf + size;
memcpy(new_buf, buffer, size);
- memcpy(curr_pos, m_unread, m_unrd_size);
-
- free(m_unread);
+ if (m_unrd_size != 0) {
+ memcpy(curr_pos, m_unread, m_unrd_size);
+ free(m_unread);
+ }
m_unread = new_buf;
m_unrd_size += size;
}
m_unread = new_buf;
m_unrd_size += size;
}
if (!peek) {
m_unrd_size -= size;
if (!peek) {
m_unrd_size -= size;
+ if (m_unrd_size == 0) {
free(m_unread);
m_unread = NULL;
}
free(m_unread);
m_unread = NULL;
}
}
m_url = url;
m_error = wxURL_NOERR;
}
m_url = url;
m_error = wxURL_NOERR;