Overview
Features
Download
Documentation
Community
Add-Ons & Services

gz compression

Please post support and help requests here.

gz compression

Postby chriso » 03 Oct 2008, 12:37


I am passing a very large string of numbers from my c++ app to a php script, which then inserts this string into a database.

At the php end I am now using gzcompress and gzuncompress to cut the mysql storage space needed down, but the data is still being sent uncompressed to the php page. Ideally I would compress before sending.

Does poco support gz compression of strings, or do you know of another library that does?

Or perhaps another compression method?

Thanks
chriso
 
Posts: 16
Joined: 28 Sep 2008, 17:42

Re: gz compression

Postby guenter » 03 Oct 2008, 12:55

For sending compressed content to the server, you can do the following:

Code: Select all

req.set("Content-Encoding", "gzip");
std::ostream rs = session.sendRequest(req);
Poco::DeflatingOutputStream deflater(rs, DeflatingStreamBuf::STREAM_GZIP);
deflater < < "Hello, world!" < < std::endl;
deflater.close()


That's basically all ;-)
guenter
 
Posts: 1138
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: gz compression

Postby chriso » 04 Oct 2008, 14:09

Thanks.

How do I get this working for form data? I am not using stream...

URI uri( postUrl.c_str() );
std::string path(uri.getPathAndQuery());
if (path.empty()) path = "/";

HTTPClientSession session(uri.getHost(), uri.getPort());
HTTPRequest req(HTTPRequest::HTTP_POST, path, HTTPMessage::HTTP_1_1);

// this isn't going to work
req.set("Content-Encoding", "gzip");


// create the form data to send
HTMLForm form(HTMLForm::ENCODING_URL);

// form values
for(int i=0; i
chriso
 
Posts: 16
Joined: 28 Sep 2008, 17:42

Re: Re: gz compression

Postby chriso » 04 Oct 2008, 14:11

Sorry, I forgot the forum doesn't like code posted.

Its the same code as this
http://pocoproject.org/poco/wiki/tiki-view_forum_thread.php?comments_parentId=1183&topics_offset=3&forumId=6
chriso
 
Posts: 16
Joined: 28 Sep 2008, 17:42

Re: Re: Re: gz compression

Postby alex » 05 Oct 2008, 14:28

> Sorry, I forgot the forum doesn't like code posted.

You should wrap your code into ~np~
Code: Select all
~/np~ / ~np~
~/np~ tags. Also, avoid double colons or replace one of them with ~np~~058~~/np~.

Alex
alex
 
Posts: 1132
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Re: gz compression

Postby guenter » 06 Oct 2008, 10:10

Code: Select all

...
form.prepareSubmit(req);
req.set("Content-Encoding", "gzip");
std::ostream rs = session.sendRequest(req);
Poco::DeflatingOutputStream deflater(rs, DeflatingStreamBuf::STREAM_GZIP);
form.write(deflater);
deflater.close();
...


guenter
 
Posts: 1138
Joined: 11 Jul 2006, 16:27
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 0 guests

cron