wxWidgets http post method example

#include <wx/sstream.h>

#include <wx/protocol/http.h>

wxHTTP http;

http.SetHeader(_T(“Content-type”), _T(“application/x-www-form-urlencoded”)); //remember to define “Content-type: application/x-www-form-urlencoded”, or remote server can’t get your posted data.
http.SetPostBuffer(_(“postdata=content”)); //it’s the data to be posted
wxInputStream *httpStream = http.GetInputStream(_T(“/login.php”));
if (http.GetError() == wxPROTO_NOERR)
wxString res;
wxStringOutputStream out_stream(&res);
// wxLogVerbose( wxString(_T(” returned document length: “)) << res.Length() );
wxMessageBox(_T(“Unable to connect!”));
, ,

wxWidgets + Code::Block Compile option

If your code::block got some error like “ld.exe cannot find -lwxmsw28u”, you may find solution from the following article.

Usually, you may compile wxWidgets with below command:

mingw32-make -f makefile.gcc BUILD=release SHARED=0 MONOLITHIC=1 UNICODE=1

mingw32-make -f makefile.gcc BUILD=debug SHARED=0 MONOLITHIC=1 UNICODE=1

According to the install.txt, the parameter description:

Starting with version 2.5.1, wxWidgets has the ability to be built as
several smaller libraries instead of single big one as used to be the case
in 2.4 and older versions. This is called “multilib build” and is the
default behaviour of makefiles. You can still build single library
(“monolithic build”) by setting MONOLITHIC variable to 1.


Build shared libraries (DLLs). By default, DLLs are not built



To build Unicode versions of the libraries, add UNICODE=1 to make invocation

(default is UNICODE=0). If you want to be able to use Unicode version on

Windows9x, you will need to set MSLU=1 as well.

This option affect name of the library (‘u’ is appended) and the directory

where the library and setup.h are store (ditto).

Please keep the consistency between the wxWidgets installed library’s setting and code::bock option.

if SHARED=1, check out the “Use wxWidgets DLL”

if MONOLITHIC=1, check out the “wxWidgets is built as a monolithic libary”

if UNICODE=1, check out the “Enable unicode”

, , ,