WxURL

From WxWiki

Jump to: navigation, search

[edit] wxURL with scripts

If you tried to retrieve a generated file from some url, your program certainly failed at it. You have to specify a Content-length header, so your filesize wil be specified.. example:

C++ Code
// ... snip ...
// This code will fail if Content-length isn't specified
wxURL *url = new wxURL(_T("http://somewhere.com/somepage.php"));
wxInputStream *in_stream;
 
in_stream = url->GetInputStream();
size_t FileSize = in_stream->GetSize();
 
char *buffer = new char [FileSize];
// ... snip ... 

So a php example of how your script should look :

PHP Code
$data = "Whatever your page should show, can also be from an SQL query";
 
header("Content-type: text/html");
header("Content-length: ".strlen($data));
 
echo $data;

[edit] wxURL and wxThread

Under Windows, wxURL and wxThread may have problems to work well together. Be sure to construct the wxURL and call wxURL::GetInputStream inside the main thread.

Personal tools