• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Content Length always 0
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Content Length always 0 (From: Brad Soe <email@hidden>)

  • Prev by Date: Re: CocoaHTTPServer and missing Content-Length headers
  • Next by Date: Re: CFSocket freezes
  • Previous by thread: Re: Content Length always 0
  • Next by thread: Socket problem using linux as server
  • Index(es):
    • Date
    • Thread