• 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: CFHTTP +authentication
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFHTTP +authentication


  • Subject: Re: CFHTTP +authentication
  • From: Alex Kac <email@hidden>
  • Date: Sun, 25 Jan 2009 14:06:07 -0600

Could you use asyncsocket? Its a Cocoa class built using CFNetworking and sockets and makes working with NSURL type stuff very very easy.

	asyncSocket = [[AsyncSocket alloc] initWithDelegate:self];
	[asyncSocket connectToHost:[url host] onPort:80 error:nil];

CFHTTPMessageRef httpRequest = CFHTTPMessageCreateRequest(kCFAllocatorDefault, (CFStringRef)@"POST", (CFURLRef)url, kCFHTTPVersion1_1);
CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("User-Agent"), (CFStringRef)@"MyUserAgent");
CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Content-Type"), (CFStringRef)headerfield);
CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Content- Length"), (CFStringRef)[NSString stringWithFormat:@"%d", [data length] + fileSize + [finalData length]]);
CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Accept"), (CFStringRef)@"text/plain, text/html, text/*");
CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Connection"), (CFStringRef)@"close");
CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Host"), (CFStringRef)[url host]);

NSData *serialData = [(NSData *)CFHTTPMessageCopySerializedMessage(httpRequest) autorelease];
CFRelease(httpRequest);


	//send the headers
	[asyncSocket writeData:serialData withTimeout:-1 tag:1];

Just an example.

On Jan 25, 2009, at 1:21 PM, John Michael Zorko wrote:


Hello, all ...

I guess this is more of a Core Foundation question, but it still seemed more apropos to this list than Carbon-dev. Please let me know if i'm wrong :-)

I'm trying to handle URLs in this format:

http://<user>:<password>@this.url.com/content

... with the <user> and <password> filled in of course. I found that NSURLConnection handled these for me, but for reasons beyond the scope of this question, NSURLConnection isn't a good choice for what i'm trying to do, so i'm using CFNetwork stuff. I've a question, though:

1. How do I get the HTTP return code? I use CFHTTPMessageCreateRequest() to create the GET request, and CFReadStreamCreateForHTTPRequest() to create a CFReadStream for said request. How do I get the response of the request?

Regards,

John

Falling You - exploring the beauty of voice and sound
http://www.fallingyou.com



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

Alex Kac - President and Founder Web Information Solutions, Inc.




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >CFHTTP +authentication (From: John Michael Zorko <email@hidden>)

  • Prev by Date: Re: Targeting Tiger
  • Next by Date: Re: Dates of the Chinese New Year
  • Previous by thread: CFHTTP +authentication
  • Next by thread: Re: CFHTTP +authentication
  • Index(es):
    • Date
    • Thread