Re: Content Length always 0
Re: Content Length always 0
- Subject: Re: Content Length always 0
- From: Becky Willrich <email@hidden>
- Date: Mon, 28 Nov 2005 10:24:41 -0800
Hi I am trying to use CFHTTPMessage to do a 'POST', but I cannot
figure out what is going wrong. I
used the code below to generate headers and the 'body', but I
noticed that no matter what the
'Content-Length' header is always set to 0, even though I try to set
it to the value using
CFHTTPMessageSetHeaderFieldValue. It could be that I am doing
something wrong, but the Apple docs
are not that great. Am I supposed to use CFHTTPMessageSetBody? That
does not seem to make a
difference. When should I use it? The current code just creates the
message, adds the headers and
uses CFHTTPMessageAppendBytes to add the body of the post (the stuff
that the Content-Length is
for). When I do a tcpdump. It looks like everything got into the
POST, but the Content-Lenght is
always 0. Can anyone give me any advice? I just want to do a simple
post with data attached.
Yes, call CFHTTPMessageSetBody() to set the POST data. Also, you need
to fully configure the CFHTTPMessageRef before calling
CFReadStreamCreateForHTTPRequest(); CFReadStreamCreateForHTTPRequest()
will take a snapshot of the request, so future changes won't make it
on to the wire.
Hope that helps,
REW
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden