/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
-#pragma implementation "http.h"
+ #pragma implementation "http.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#if wxUSE_SOCKETS
-#ifndef WX_PRECOMP
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include "wx/string.h"
wxString buf;
buf.Printf(_T("%s: %s\n\r"), head->GetKeyString(), str->GetData());
- wxWX2MBbuf cbuf = buf.mb_str();
+ const wxWX2MBbuf cbuf = buf.mb_str();
Write(cbuf, strlen(cbuf));
head = head->Next();
bool wxHTTP::ParseHeaders()
{
wxString line;
+ wxStringTokenizer tokenzr;
m_headers.Clear();
m_read = TRUE;
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);
}
{
char *tmp_buf;
char buf[HTTP_BSIZE];
- wxWX2MBbuf pathbuf = path.mb_str();
+ const wxWX2MBbuf pathbuf = path.mb_str();
switch (req) {
case wxHTTP_GET:
}
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");
if (!GetHeader(_T("Content-Length")).IsEmpty())
inp_stream->m_httpsize = wxAtoi(WXSTRINGCAST GetHeader(_T("Content-Length")));
+ SetFlags(WAITALL);
return inp_stream;
}