Am 02.04.2012 06:48, schrieb Jean-Michel Caricand:
Le 02/04/2012 00:34, Jean-Michel Caricand a écrit :
Hello,

I need to convert this Perl code to C++ with cxxtools. Do you have a
example ?

Thanks,

Jean-Michel

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general
Ouups...

use LWP::UserAgent;

my $url = 'http://localhost:8000/authors/1/bio';
my $bio = 'dieu';
my $req = HTTP::Request->new(GET =>  $url, HTTP::Headers->new, $bio);
$req->content_type('text/plain');
$req->content_length(length $bio);

my $res = LWP::UserAgent->new->request($req);

print $res->status_line, "\n";
print $res->content;


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general
So you need some kind of a proxy. Here we go:

   <%pre>
   #include <cxxtools/http/client.h>
   </%pre>
   <%cpp>

   cxxtools::http::Client client("localhost", 8000);

   std::string content = client.get("/");
   reply.setContentType("text/plain");
   reply.out() << content;

   </%cpp>


And link this against libcxxtools-http (linker flag -lcxxtools-http). This is the simplest API to the http-client of cxxtools.

Tommi
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to