Re: Setting HTTP Status Code/Description after CFHTTPMessageCreateEmpty
Re: Setting HTTP Status Code/Description after CFHTTPMessageCreateEmpty
- Subject: Re: Setting HTTP Status Code/Description after CFHTTPMessageCreateEmpty
- From: Becky Willrich <email@hidden>
- Date: Sun, 1 Apr 2007 16:22:03 -0700
I'm having trouble figuring out how to set the HTTP status code and
description if I create a CFHTTPMessage using
CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE). The
CFHTTPMessageCreateResponse function has arguments for the status
code and description, but there doesn't seem to be a way to set
those if I use CFHTTPMessageCreateEmpty. Are there functions to set
those values?
CFHTTPMessageCreateEmpty() is really only intended for use when
you're populating the message from a byte stream (like if you're
receiving it from a server); you call CFHTTPMessageCreateEmpty() and
then as they bytes arrive, you call CFHTTPMessageAppendBytes(). If
you're constructing the message programmatically (i.e. you know it's
a response with a 404 status code and you have the pre-computed
header dict somewhere), you're better off using
CFHTTPMessageCreateResponse() plus CFHTTPMessageSetHeaderFieldValue().
However, to answer your question - if you're starting with
CFHTTPMessageCreateEmpty(), you'd call CFHTTPMessageAppendBytes()
with the appropriate bytes for the response type you want to set the
status code.
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