Hi,
I am using the winhttp library in C++ to post data to the server. Now I want to compress the data in gzip format before sending. I am not too sure sure of all the servers I am dealing with can handle compressed data. So I need some way to know if the server can handle it or not. I know that I can send a header "Accept Encoding" if I want to tell the server that I can handle compressed data, but I do not know how to ask the server if it can handle compressed data. I tried googling but there is hardly any information about sending compressed data to the server.
I know that strictly speaking this is not a c/c++ question and I apologize for that but I could not find a forum for problems like these.
Thanks
Harsha
11 replies to this topic
#1
Posted 06 April 2010 - 07:41 PM
|
|
|
#2
Posted 06 April 2010 - 07:55 PM
Content-Type: application/gzip
The server should complain if it doesn't like it. It'll probably be a 415 error message.
The server should complain if it doesn't like it. It'll probably be a 415 error message.
sudo rm -rf /
#3
Posted 06 April 2010 - 08:19 PM
Ok. But the reply from the server, when will it tell the client about the error message? Like posting will be done at WinHttpSendRequest, and the header would be sent earlier using winhttpaddheaderrequest. I am guessing I will have to do a qeuryheader to check for the status code but that can only be done after receiveresponse right ?? So if I get to know that the server does not support gzip then I will have to use winhttpsendrequest again to send the data in normal form? Please correct me if I am wrong.
and thanks for you reply
and thanks for you reply
#4
Posted 06 April 2010 - 08:27 PM
As far as I know, yes. I haven't done WinHTTP in almost a year, so I don't know the exact functions you need to call, but the basic idea behind what you said is right.
sudo rm -rf /
#5
Posted 06 April 2010 - 09:11 PM
ok. thanks again for your help.
#6
Posted 06 April 2010 - 09:23 PM
#7
Posted 07 April 2010 - 11:40 PM
hey,
I just realised that content-type: application/gzip actually does not work. I got a 500 status code. infact content-encoding: gzip worked.
Harsha
I just realised that content-type: application/gzip actually does not work. I got a 500 status code. infact content-encoding: gzip worked.
Harsha
#8
Posted 07 April 2010 - 11:47 PM
Oops...should be Content-Type: application/x-gzip. But if the Content-Encoding thing works, then that's fine. You should be careful, though, as they're not the same thing.
Content-Type: application/x-gzip means that whatever you're sending is a .gz archive, no matter what encoding (e.g. Base64, 7bit, etc.) you send it in.
Content-Encoding: gzip means that you're sending something that's gzipped, but the actual content could be something else like a webpage or an image file. Is this what you wanted?
Content-Type: application/x-gzip means that whatever you're sending is a .gz archive, no matter what encoding (e.g. Base64, 7bit, etc.) you send it in.
Content-Encoding: gzip means that you're sending something that's gzipped, but the actual content could be something else like a webpage or an image file. Is this what you wanted?
sudo rm -rf /
#9
Posted 07 April 2010 - 11:51 PM
Yes content-encoding is what I actually wanted. I realised the difference sometime earlier but was still having some problems in running my program. anyhow finally it worked.
thanks again for your reply
thanks again for your reply
#10
Posted 08 April 2010 - 12:10 AM
#11
Posted 08 April 2010 - 09:59 AM
dargueta said:
No problem. If you want me to confuse you, just ask. :D
Root Beer == System Administrator's Beer
Download the new operating system programming kit! (some assembly required)
Download the new operating system programming kit! (some assembly required)
#12
Posted 08 April 2010 - 01:09 PM
dcs has already done that for me a few times. If you make a mistake, he will catch it.
sudo rm -rf /
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









